16 สิงหาคม 2555

ใช้ฟอนต์บนเว็บไซต์ด้วย cufont

ขั้นตอนต่าง ๆ อ้างอิงจากบทความ http://www.select2web.com/jquery/font-on-web-by-cufon.html

1. ก็อปปี้โค้ดไฟล์ Cufon.yui.js ที่หน้า https://cdnjs.cloudflare.com/ajax/libs/cufon/1.09i/cufon-yui.js

2. แปลงฟ้อนท์ ที่ http://cufon.shoqolate.com/generate/

ในขั้นตอนการนำเอาฟ้อนท์ที่อยากใช้ไปแปลง เพื่อให้แสดงภาษาไทย ให้ทำดังนี้



- เลือกไฟล์ฟ้อนท์ ที่ต้องการแปลง ด้านล่างข้อความ Select the font you'd like to use โดยจะมีให้เลือกว่าจะเอา ตัวหนังสือ ธรรมดา ตัวหนา ตัวเอียง ก็ให้เลือกตามไฟล์ .ttf ที่เรามีได้เลย

- กรอก ชื่อไฟล์ .js ที่ต้องการหลังจากทำการแปลง บน textbox ด้านล่างข้อความ
Use the following value as the font-family of the generated font (optional)

- ติ๊กเลือกที่ Checkbox หน้า The EULAs of these fonts allow Web Embedding (without Adobe Flash)

- ติ๊กเลือกที่ Checkbox หน้า All Includes all available glyphs। Highly unrecommended

- ติ๊กเลือกที่ Checkbox หน้า I acknowledge and accept these terms

จากนั้นกดที่ Let's do this! ก็จะมีไดอะล๊อกบ๊อกเพื่อให้บันทึกเป็นไฟล์ .js ตามชื่อที่เราป้อน

โค้ดตัวอย่างที่ทำการทดลอง

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/cufon-yui.js" type="text/javascript"></script>
<script src="js/TH_Niramit_700.font.js" type="text/javascript"></script>
<script type="text/javascript">
Cufon.replace('h1');
</script>
<style type="text/css">
h1 {
font-size:40px;
color: #2A2A2A
}
</style>
<body>
<h1>หนุ่มไปขลิบอวัยวะเพศ หมอพลาดทำไหม้เกรียม !</h1>
</body>
</html>

ผลลัพธ์ที่ได้ก็จะเป็นดังรูปด้านล่างเลยครับ

ไม่มีความคิดเห็น:

แสดงความคิดเห็น