unit text_rasterizers; {$MODE OBJFPC} {$M+} // TODO add an interface and allow others to provide their own rasterizer? // FIXME finish. interface uses type_fixes, fonts, framebuffers, rectangles, graphics_2D; type TRasterizerOnFramebuffer = class constructor Create(const aFramebuffer : TFramebufferInfo); { can only handle UTF-8 and Wide Strings, so sue me. depending on the Pen, does not necessarily actually draw the text onto the framebuffer. In that case, it can be used to determine the will-be size of text. (aX, aY) are the coordinates of the baseline (before the first character of the text). } function DrawText(aX, aY : TCoordinate; aDirection : TTextDirection; aText : TWideString) : TRectangle; function DrawText(aX, aY : TCoordinate; aDirection : TTextDirection; aText : TUTF8String) : TRectangle; property Font : IFont; property Pen : IPen; property Height : TCardinal; { desired text height, ascent + descent, in pixels. } end; implementation { Unicode Character Ranges C0 Controls and Basic Latin U+0000 – U+007F (0–127) C1 Controls and Latin-1 Supplement U+0080 – U+00FF (128–255) Latin Extended-A U+0100 – U+017F (256–383) Latin Extended-B U+0180 – U+024F (384–591) IPA Extensions U+0250 – U+02AF (592–687) Spacing Modifier Letters U+02B0 – U+02FF (688–767) Combining Diacritical Marks U+0300 – U+036F (768–879) Greek U+0370 – U+03FF (880–1023) Cyrillic U+0400 – U+04FF (1024–1279) Cyrillic Supplement U+0500 – U+052F (1280–1327) Armenian U+0530 – U+058F (1328–1423) Hebrew U+0590 – U+05FF (1424–1535) Arabic U+0600 – U+06FF (1536–1791) Syriac U+0700 – U+074F (1792–1871) Arabic Supplement U+0750 – U+077F (1872–1919) Thaana U+0780 – U+07BF (1920–1983) N’Ko U+07C0 – U+07FF (1984–2047) Devanagari U+0900 – U+097F (2304–2431) Bengali U+0980 – U+09FF (2432–2559) Gurmukhi U+0A00 – U+0A7F (2560–2687) Gujarati U+0A80 – U+0AFF (2688–2815) Oriya U+0B00 – U+0B7F (2816–2943) Tamil U+0B80 – U+0BFF (2944–3071) Telugu U+0C00 – U+0C7F (3072–3199) Kannada U+0C80 – U+0CFF (3200–3327) Malayalam U+0D00 – U+0D7F (3328–3455) Sinhala U+0D80 – U+0DFF (3456–3583) Thai U+0E00 – U+0E7F (3584–3711) Lao U+0E80 – U+0EFF (3712–3839) Tibetan U+0F00 – U+0FFF (3840–4095) Myanmar U+1000 – U+109F (4096–4255) Georgian U+10A0 – U+10FF (4256–4351) Hangul Jamo U+1100 – U+11FF (4352–4607) Ethiopic U+1200 – U+137F (4608–4991) Ethiopic Supplement U+1380 – U+139F (4992–5023) Cherokee U+13A0 – U+13FF (5024–5119) Unified Canadian Aboriginal Syllabics U+1400 – U+167F (5120–5759) Ogham U+1680 – U+169F (5760–5791) Runic U+16A0 – U+16FF (5792–5887) Tagalog U+1700 – U+171F (5888–5919) Hanunσo U+1720 – U+173F (5920–5951) Buhid U+1740 – U+175F (5952–5983) Tagbanwa U+1760 – U+177F (5984–6015) Khmer U+1780 – U+17FF (6016–6143) Mongolian U+1800 – U+18AF (6144–6319) Limbu U+1900 – U+194F (6400–6479) Tai Le U+1950 – U+197F (6480–6527) New Tai Lue U+1980 – U+19DF (6528–6623) Khmer Symbols U+19E0 – U+19FF (6624–6655) Buginese U+1A00 – U+1A1F (6656–6687) Balinese U+1B00 – U+1B7F (6912–7039) Sundanese U+1B80 – U+1BBF (7040–7103) Lepcha U+1C00 – U+1C4F (7168–7247) Ol Chiki U+1C50 – U+1C7F (7040–7295) Phonetic Extensions U+1D00 – U+1D7F (7424–7551) Phonetic Extensions Supplement U+1D80 – U+1DBF (7552–7615) Combining Diacritical Marks Supplement U+1DC0 – U+1DFF (7616–7679) Latin Extended Additional U+1E00 – U+1EFF (7680–7935) Greek Extended U+1F00 – U+1FFF (7936–8191) General Punctuation U+2000 – U+206F (8192–8303) Superscripts and Subscripts U+2070 – U+209F (8304–8351) Currency Symbols U+20A0 – U+20CF (8352–8399) Combining Diacritical Marks for Symbols U+20D0 – U+20FF (8400–8447) Letterlike Symbols U+2100 – U+214F (8448–8527) Number Forms U+2150 – U+218F (8528–8591) Arrows U+2190 – U+21FF (8592–8703) Mathematical Operators U+2200 – U+22FF (8704–8959) Miscellaneous Technical U+2300 – U+23FF (8960–9215) Control Pictures U+2400 – U+243F (9216–9279) Optical Character Recognition U+2440 – U+245F (9280–9311) Enclosed Alphanumerics U+2460 – U+24FF (9312–9471) Box Drawing U+2500 – U+257F (9472–9599) Block Elements U+2580 – U+259F (9600–9631) Geometric Shapes U+25A0 – U+25FF (9632–9727) Miscellaneous Symbols U+2600 – U+26FF (9728–9983) Dingbats U+2700 – U+27BF (9984–10175) Miscellaneous Mathematical Symbols-A U+27C0 – U+27EF (10176– 10223) Supplemental Arrows-A U+27F0 – U+27FF (10224–10239) Braille Patterns U+2800 – U+28FF (10240–10495) Supplemental Arrows-B U+2900 – U+297F (10496–10623) Miscellaneous Mathematical Symbols-B U+2980 – U+29FF (10624–10751) Supplemental Mathematical Operators U+2A00 – U+2AFF (10752–11007) Miscellaneous Symbols and Arrows U+2B00 – U+2BFF (11008–11263) Glagolitic U+2C00 – U+2C5F (11264–11359) Latin Extended-C U+2C60 – U+2C7F (11360–11391) Coptic U+2C80 – U+2CFF (11392–11519) Georgian Supplement U+2D00 – U+2D2F (11520–11567) Tifinagh U+2D30 – U+2D7F (11568–11647) Ethiopic Extended U+2D80 – U+2DDF (11648–11743) Cyrillic Extended-A U+2DE0 – U+2DFF (11744–11775) Supplemental Punctuation U+2E00 – U+2E7F (11776–11903) CJK Radicals Supplement U+2E80 – U+2EFF (11904–12031) KangXi Radicals U+2F00 – U+2FDF (12032–12255) Ideographic Description Characters U+2FF0 – U+2FFF (12272–12287) CJK Symbols and Punctuation U+3000 – U+303F (12288–12351) Hiragana U+3040 – U+309F (12352–12447) Katakana U+30A0 – U+30FF (12448–12543) Bopomofo U+3100 – U+312F (12544–12591) Hangul Compatibility Jamo U+3130 – U+318F (12592–12687) Kanbun U+3190 – U+319F (12688–12703) Bopomofo Extended U+31A0 – U+31BF (12704–12735) CJK Strokes U+31C0 – U+31EF (12736–12783) Katakana Phonetic Extensions U+31F0 – U+31FF (12784–12799) Enclosed CJK Letters and Months U+3200 – U+32FF (12800–13055) CJK Compatibility U+3300 – U+33FF (13056–13311) CJK Unified Ideographs Extension A U+3400 – U+4DB5 (13312–19893) Yijing Hexagram Symbols U+4DC0 – U+4DFF (19904–19967) CJK Unified Ideographs U+4E00 – U+9FBB (19968–40891) Yi Syllables U+A000 – U+A48F (40960–42127) Yi Radicals U+A490 – U+A4CF (42128–42191) Vai U+A500 – U+A63F (42240–42559) Cyrillic Extended-B U+A640 – U+A69F (42560–42655) Modifier Tone Letters U+A700 – U+A71F (42752–42783) Latin Extended-D U+A720 – U+A7FF (42784–43007) Syloti Nagri U+A800 – U+A82F (43008–43055) Phags-pa U+A840 – U+A87F (43072–43135) Saurashtra U+A880 – U+A8DF (43136–43311) Kayah Li U+A900 – U+A92F (43264–43231) Rejang U+A930 – U+A95F (43312–43359) Cham U+AA00 – U+AA5F (43520–43615) Hangul Syllables U+AC00 – U+D7A3 (44032–55203) CJK Compatibility Ideographs U+F900 – U+FAFF (63744–64255) Alphabetic Presentation Forms U+FB00 – U+FB4F (64256–64335) Arabic Presentation Forms-A U+FB50 – U+FDFF (64336–65023) Variation Selectors U+FE00 – U+FE0F (65024–65039) Vertical Forms U+FE10 – U+FE1F (65040–65055) Combining Half Marks U+FE20 – U+FE2F (65056–65071) CJK Compatibility Forms U+FE30 – U+FE4F (65072–65103) Small Form Variants U+FE50 – U+FE6F (65104–65135) Arabic Presentation Forms-B U+FE70 – U+FEFF (65136–65279) Halfwidth and Fullwidth Forms U+FF00 – U+FFEF (65280–65519) Specials U+FEFF, U+FFF0 – U+FFFF (65279, 65520–65535) Linear B Syllabary U+10000 – U+1007F (65536–65663) Linear B Ideograms U+10080 – U+100FF (65664–65791) Aegean Numbers U+10100 – U+1013F (65792–65855) Ancient Greek Numbers U+10140 – U+1018F (65856–65935) Ancient Symbols U+10190 – U+101CF (65936–65999) Phaistos Disc U+101D0 – U+101FF (66000–66047) Lycian U+10280 – U+1029F (66176–66207) Carian U+102A0 – U+102DF (66208–66271) Old Italic U+10300 – U+1032F (66304–66351) Gothic U+10330 – U+1034F (66352–66383) Ugaritic U+10380 – U+1039F (66432–66463) Old Persian U+103A0 – U+103DF (66464–66527) Deseret U+10400 – U+1044F (66560–66639) Shavian U+10450 – U+1047F (66640–66687) Osmanya U+10480 – U+104AF (66688–66735) Cypriot Syllabary U+10800 – U+1083F (67584–67647) Phoenician U+10900 – U+1091F (67840–67871) Lydian U+10920 – U+1093F (67872–67903) Kharoshthi U+10A00 – U+10A5F (68096–68191) Cuneiform U+12000 – U+123FF (73728–74751) Cuneiform Numbers and Punctuation U+12400 – U+1247F (74752–74879) Byzantine Musical Symbols U+1D000 – U+1D0FF (118784–119039) Musical Symbols U+1D100 – U+1D1FF (119040–119295) Ancient Greek Musical Notation U+1D200 – U+1D24F (119296–119375) Tai Xuan Jing Symbols U+1D300 – U+1D35F (119552–119647) Counting Rod Numerals U+1D360 – U+1D37F (119648–119679) Mathematical Alphanumeric Symbols U+1D400 – U+1D7FF (119808–120831) Mahjong Tiles U+1F000 – U+1F02F (126976–127023) Domino Tiles U+1F030 – U+1F09F (127024–127135) CJK Unified Ideographs Extension B U+20000 – U+2A6D6 (131072–173782) CJK Compatibility Ideographs Supplement U+2F800 – U+2FA1F (194560–195103) Tags U+E0000 – U+E007F (917504–917631) Variation Selectors Supplement U+E0100 – U+E01EF (917760–917999) } constructor TRasterizerOnFramebuffer.Create(const aFramebuffer : TFramebufferInfo); begin end; function TRasterizerOnFramebuffer.DrawText(aX, aY : TCoordinate; aDirection : TTextDirection; aText : TWideString) : TRectangle; begin end; function TRasterizerOnFramebuffer.DrawText(aX, aY : TCoordinate; aDirection : TTextDirection; aText : TUTF8String) : TRectangle; begin end; end.