This commit is contained in:
treeform 2022-05-14 09:57:50 -07:00
parent dffe86074f
commit 655099a64e
4 changed files with 54 additions and 51 deletions

View file

@ -949,10 +949,19 @@ const cffStandardStrings = [
const TOP_DICT_META = { const TOP_DICT_META = {
0: "version", 0: "version",
1: "notice", 1: "notice",
1200: "copyright",
2: "fullName", 2: "fullName",
3: "familyName", 3: "familyName",
4: "weight", 4: "weight",
5: "fontBBox",
13: "uniqueId",
14: "xuid",
15: "charset",
16: "encoding",
17: "charStrings",
18: "private",
1200: "copyright",
1201: "isFixedPitch", 1201: "isFixedPitch",
1202: "italicAngle", 1202: "italicAngle",
1203: "underlinePosition", 1203: "underlinePosition",
@ -960,14 +969,7 @@ const TOP_DICT_META = {
1205: "paintType", 1205: "paintType",
1206: "charstringType", 1206: "charstringType",
1207: "fontMatrix", 1207: "fontMatrix",
13: "uniqueId",
5: "fontBBox",
1208: "strokeWidth", 1208: "strokeWidth",
14: "xuid",
15: "charset",
16: "encoding",
17: "charStrings",
18: "private",
1230: "ros", 1230: "ros",
1231: "cidFontVersion", 1231: "cidFontVersion",
1232: "cidFontRevision", 1232: "cidFontRevision",

Binary file not shown.

BIN
tests/fonts/PTSans.ttc Normal file

Binary file not shown.

View file

@ -1,51 +1,52 @@
import pixie, strformat, unicode, pixie/fontformats/opentype import pixie, strformat, unicode, pixie/fontformats/opentype
block: block:
var font = readFont("/Windows/Fonts/simsun.ttc") var font = readFont("tests/fonts/PTSans.ttc")
font.size = 72 font.size = 72
let image = newImage(220, 100) let image = newImage(200, 100)
image.fill(rgba(255, 255, 255, 255)) image.fill(rgba(255, 255, 255, 255))
image.fillText(font, "大目鳥") image.fillText(font, "AbCd")
image.writeFile("ttc.png") # image.writeFile("ttc.png")
block: block:
var fonts = parseOpenTypeCollection(readFile("/Windows/Fonts/simsun.ttc")) var fonts = parseOpenTypeCollection(readFile("tests/fonts/PTSans.ttc"))
for font in fonts: for i, font in fonts:
echo font.fullName echo i, ": ", font.fullName
block: when defined(windows):
let files = @[ block:
"/Windows/Fonts/batang.ttc", let files = @[
"/Windows/Fonts/BIZ-UDGothicB.ttc", "/Windows/Fonts/batang.ttc",
"/Windows/Fonts/BIZ-UDGothicR.ttc", "/Windows/Fonts/BIZ-UDGothicB.ttc",
"/Windows/Fonts/BIZ-UDMinchoM.ttc", "/Windows/Fonts/BIZ-UDGothicR.ttc",
"/Windows/Fonts/cambria.ttc", "/Windows/Fonts/BIZ-UDMinchoM.ttc",
"/Windows/Fonts/gulim.ttc", "/Windows/Fonts/cambria.ttc",
"/Windows/Fonts/meiryo.ttc", "/Windows/Fonts/gulim.ttc",
"/Windows/Fonts/meiryob.ttc", "/Windows/Fonts/meiryo.ttc",
"/Windows/Fonts/mingliub.ttc", "/Windows/Fonts/meiryob.ttc",
"/Windows/Fonts/msgothic.ttc", "/Windows/Fonts/mingliub.ttc",
"/Windows/Fonts/msjh.ttc", "/Windows/Fonts/msgothic.ttc",
"/Windows/Fonts/msjhbd.ttc", "/Windows/Fonts/msjh.ttc",
"/Windows/Fonts/msjhl.ttc", "/Windows/Fonts/msjhbd.ttc",
"/Windows/Fonts/msmincho.ttc", "/Windows/Fonts/msjhl.ttc",
"/Windows/Fonts/msyh.ttc", "/Windows/Fonts/msmincho.ttc",
"/Windows/Fonts/msyhbd.ttc", "/Windows/Fonts/msyh.ttc",
"/Windows/Fonts/msyhl.ttc", "/Windows/Fonts/msyhbd.ttc",
"/Windows/Fonts/simsun.ttc", "/Windows/Fonts/msyhl.ttc",
"/Windows/Fonts/Sitka.ttc", "/Windows/Fonts/simsun.ttc",
"/Windows/Fonts/SitkaB.ttc", "/Windows/Fonts/Sitka.ttc",
"/Windows/Fonts/SitkaI.ttc", "/Windows/Fonts/SitkaB.ttc",
"/Windows/Fonts/SitkaZ.ttc", "/Windows/Fonts/SitkaI.ttc",
"/Windows/Fonts/UDDigiKyokashoN-B.ttc", "/Windows/Fonts/SitkaZ.ttc",
"/Windows/Fonts/UDDigiKyokashoN-R.ttc", "/Windows/Fonts/UDDigiKyokashoN-B.ttc",
"/Windows/Fonts/YuGothB.ttc", "/Windows/Fonts/UDDigiKyokashoN-R.ttc",
"/Windows/Fonts/YuGothL.ttc", "/Windows/Fonts/YuGothB.ttc",
"/Windows/Fonts/YuGothM.ttc", "/Windows/Fonts/YuGothL.ttc",
"/Windows/Fonts/YuGothR.ttc", "/Windows/Fonts/YuGothM.ttc",
] "/Windows/Fonts/YuGothR.ttc",
for file in files: ]
echo file for file in files:
var fonts = parseOpenTypeCollection(readFile(file)) echo file
for i, font in fonts: var fonts = parseOpenTypeCollection(readFile(file))
echo " ", i, ": ", font.fullName for i, font in fonts:
echo " ", i, ": ", font.fullName