Closed kdbeall closed 4 years ago
@sysalto I have looked more into the codebase, and learned more about fonts. I found that there exists a TtfParser. However, it seems no Ttf fonts are included. It may be possible to support CJK characters via TrueType.
@sysalto I think I found a potential way to get the CJK characters via TrueType using the API. however, I did not find the documentation on the wiki until today. I've opened a pull request to add a link to the documentation.
Okay, so, there's still an issue it seems because Japanese, Korean, and Chinese seem to use .ttc files instead of .ttf files. Additionally, not all latin-based .ttf fonts are parsed properly.
@sysalto I've reviewed more and I've found out that TtfParser assumes Latin characters.
def getFontMetric(): FontMetric = {
val fontName = name.nameRecordList.filter(item => item.nameID.value == 4).head.str
val l1 = cMap.charGlypList.map { case (char, index) => char -> hmtx.hMetrics(index).advanceWidth.value / 1f / head.unitsPerEm.value }
val firstChar = 13
val lastChar = 255
val l2 = (for (i <- firstChar to lastChar) yield l1.get(i)).
filter(item => item.isDefined).map(item => (item.get * 1000f).toShort).toList
val glyphWidth = new GlyphWidth(firstChar.toShort, lastChar.toShort, l2)
val fontDescriptor = new EmbeddedFontDescriptor(convertToPdfUnits(os2.sTypoAscender.value),
convertToPdfUnits(os2.sCapHeight.value),
convertToPdfUnits(os2.sTypoDescender.value), fontBBox, post.italicAngle.value.toShort, 1 << 5, glyphWidth)
val result = new FontMetric(fontName, l1, (0, 0), Some(fontDescriptor))
result
}
getFontMetric()
Done. The new version 1.0.7-SNAPSHOT added otf and cjk support. For now it includes entire font. We are working to include only the necessary glyphs for the next version.
@sysalto thanks for the update. Regarding including the necessary glyphs, we've implemented font subsetting, I can make a pull request if you are interested in it.
Can ReactiveReports render Chinese (both simplified and traditional), Korean, and Japanese? While attempting to print a report with Korean,
???
is output. The report has a mix of English and Korean. From the README, I see there is "Built in support for French and Spanish character set".