TABLE OF CONTENTS
- 1. ScPovPlot3D/TextExt.inc
- 1.1. TextExt.inc/Text
- 1.2. TextExt.inc/TextExt
- 1.3. TextExt.inc/UnicodifyPL
- 1.4. TextExt.inc/GetTextExtent
- 1.5. TextExt.inc/InsrtChr
- 1.6. TextExt.inc/Set_TFont, _FF
- 1.7. TextExt.inc/SetLDpth
- 1.8. TextExt.inc/SetSpcStub
- 1.9. TextExt.inc/TrimStr
- 1.10. TextExt.inc/TrimStrC
- 1.11. TextExt.inc/FormattingConstants
- 1.12. TextExt.inc/_ArNap
- 1.13. TextExt.inc/Fonts, _FLibera, _FCourierI, _FTimes, _FSegoa, _FArialUni, _FArialRond, _FCooper, _FCorsiva
- 1.14. TextExt.inc/SubSupScale, SubShift, SupShift, UpPos, DnPos, SpcStub, _DotScalingFactor, _Dp, _HCur, _VCur, _TLen, _RFac, __Cnt
- 1.15. TextExt.inc/UTFCodes
ScPovPlot3D/TextExt.inc [ Modules ]
PURPOSE
Text object extensions,
Fig.[TextExt] Example of implementation of this module. At top Text containing polish national characters is displayed. Do not even try to pronounciate it ;)
VERSION
4.0.0, tested on PovRay 3.7.
AUTHOR
Janusz Opi³a Ph.D.
jmo{at}agh.edu.pl, janusz.opila{at}gmail.com Dept. of Applied Informatics, https://www.facebook.com/KatedraInformatykiStosowanejWZAGH/ http://kis.zarz.agh.edu.pl/ AGH University of Science & Technology, Cracow, Poland http://www.zarz.agh.edu.pl/English/index.asp Maintained by Janusz Opi³a Ph.D. Homepage: http://scpovplot3d.sourceforge.net
HISTORY
2018-02-03, 'tau' added 2017-09-25, some german "umlauts" added 2017-04-12, '¯' letter corrected, minor changes 2017-02-03, macro added GetTextExtent() - returns appr. horizontal Text size 2016-02-17, 3.2.0.3 - nabla unicode character correction 2016-01-29, 3.2.0.2 - macros TrimStr(), TrimStrC() added. 2016-01-28, 3.2.0.1 - minor corrections, added some symbols
COPYRIGHT
GNU GPL v.3 License (c) 2012-now by Janusz Opi³a Ph.D. AGH University of Science and Technology
TextExt.inc/Text [ Main macros ]
[ Top ] [ TextExt.inc ] [ Main macros ]
PURPOSE
Recursively parses string _Nap passed to makro and returns part of it but with super-scripts inserted as solitary characters
front-end to parsing macro REMARK: This should work as expected with ANY font Usage: Formats string due to special sequences Ex: prepend subscript with underscore "_", longer subscripts enclose in curly paranthesis _{j,i_2} and so on
SYNOPSIS
#macro Text( _Nap ) // front-end to TextExt() macro
INPUTS
_Nap - string to parse, returns remainder of non parsed input.
SEE ALSO
UnicodifyPL ()
TextExt.inc/TextExt [ Main macros ]
[ Top ] [ TextExt.inc ] [ Main macros ]
PURPOSE
Recursively parses string _Nap passed to makro and returns part of it but with super-scripts inserted as solitary characters
Usually one don't need to use this macro directly. It is designed to be called indirectly by Text () front macro. REMARK: This should work as expected with ANY font. Usage: Formats string due to escape sequences Prepend subscript with underscore "_", longer subscripts enclose in curly paranthesis _{j,i_2} and so on works recursively
SYNOPSIS
#macro TextExt( _ps, _hc, _vc, _sc) // string to parse is stored in a global array, see INPUTS section // character - any UTF character // Text = [["" | "{" | "#" | character ] | ... ] // # command prefix // ## - '#' itself // #v - make FOLLOWING character or characters enclosed in curly brackets {} a vector ex. #vF - Force vector // ` - /left apostrophe/ - accented letter (polish '¹' for example) // {} // ^ // _ // | - short space // " " - regular space
INPUTS
_ps - string to parse is stored in global array _ArrNap[], returns (by ref) position of next char, to parse _hc - horizontal position of cursor _vc - vertical position of cursor _sc - local size modifier. Final size of Text should be set in scene file (presumedly by scale<> statement ).
SEE ALSO
UnicodifyPL () Text ()
TextExt.inc/UnicodifyPL [ Main macros ]
[ Top ] [ TextExt.inc ] [ Main macros ]
PURPOSE
Parses string _In passed to makro and returns copy of it as _Out with subscripts inserted
WARNING: not every font defines polish "Ogonki". WARNING2: this is rather obsolete Usage: prepend each polish national character changed to latin base with " ` " (left apostrophe). Ex. "¯" => "`Z" To insert left apostrophe just put it in twice: "``" => "`"
SYNOPSIS
#macro UnicodifyPL(_In) // ~a => ¹ and so on.
INPUTS
_In - string to parse, returns result of parsing as well
SEE ALSO
Text ()
TextExt.inc/GetTextExtent [ Helper macros ]
[ Top ] [ TextExt.inc ] [ Helper macros ]
PURPOSE
Returns horizontal (x-axis) Text block extent in POV units
SYNOPSIS
#macro GetTextExtent()
INPUTS
None
SEE ALSO
None
TextExt.inc/InsrtChr [ Helper macros ]
[ Top ] [ TextExt.inc ] [ Helper macros ]
PURPOSE
Inserts single char into scene "as is" without processing
SYNOPSIS
#macro InsrtChr(_Cc, _hc, _vc, _sc)
INPUTS
_Cc - single character string to put, returns result of parsing as well _hc - horizonatl cursor _vc - vertical cursor _sc - scaling factor
SEE ALSO
ParseText ()
TextExt.inc/Set_TFont, _FF [ Helper macros ]
[ Top ] [ TextExt.inc ] [ Helper macros ]
PURPOSE
Defines font for textual elements of the scene
WARNING: Font must exist in the host operating system default setting "arial.ttf" should be safe on Windows, as well as on some GNU/Linux distros You may also use Helvetica on GNU\Linux systems, as it should exist by default
SYNOPSIS
#declare _FF = _FArial; // Default font for texts object handled by this tool macros set #macro Set_TFont(_TxtFnt)
INPUTS
_FF - string containing name of the font, ex. "Arial.ttf" WARNING: One have to use it BEFORE parsing call to Text() macros!
SEE ALSO
Set_TextFont ()
TextExt.inc/SetLDpth [ Helper macros ]
[ Top ] [ TextExt.inc ] [ Helper macros ]
PURPOSE
Sets "depth" of the Text object
SYNOPSIS
#macro SetLDpth(_d ) // string _spc declares depth of character(s)
INPUTS
_d - positive float
TextExt.inc/SetSpcStub [ Helper macros ]
[ Top ] [ TextExt.inc ] [ Helper macros ]
PURPOSE
Sets character imitiating 'space'
SYNOPSIS
#macro SetSpcStub(_spc ) // string _spc declares space width character(s)
INPUTS
string _spc - may be "-" or "." or even "asd"
TextExt.inc/TrimStr [ Helper macros ]
[ Top ] [ TextExt.inc ] [ Helper macros ]
PURPOSE
Removes trailing spaces from the string passed. Spaces are expected before and after the core Text.
SYNOPSIS
#macro TrimStr ( _s )
INPUTS
string - Text to deal with.
OUTPUTS
string - stripped Text.
EXAMPLE
* #declare SomeStr = " ABC DE "; * #declare SomeStr = TrimStr(SomeStr); * Now string SomeStr equals: "ABC DE". Intern spaces are preserved.
SEE ALSO
TextExt.inc/TrimStrC [ Helper macros ]
[ Top ] [ TextExt.inc ] [ Helper macros ]
PURPOSE
Removes trailing spaces from the string passed. Spaces are expected before and after the core Text.
SYNOPSIS
#macro TrimStrC ( _s, _c )
INPUTS
string - Text to deal with. char - charcter to skip over
OUTPUTS
string - stripped Text.
EXAMPLE
* #declare SomeStr = " ABC DE "; * #declare SomeStr = TrimStr(SomeStr); * Now string SomeStr equals: "ABC DE". Intern spaces are preserved.
SEE ALSO
TextExt.inc/FormattingConstants [ Constants ]
[ Top ] [ TextExt.inc ] [ Constants ]
PURPOSE
Escape sequences for parsing subsystem. Introductory stage, no debugging messages!
WARNING: may change in next releases (but i hope don't)!
SOURCE
// `a - (LEFT apostrophe) 'ogonkified' letter - here polish accented as of now // _ - sub-script next character // ^ - super-script next character // { } - block of super/sub-script (direct brackets on regular line) // . - inserts dot. Surprised? Utilizes superellipsoid object on regular line, raw dot in indexes. // " " - regular space (just hit 'Space') // `| - vertical bar in indexes, but.. // | - short space on regular line // double `` means single ` (not in super/sub-script) // double ^^ means single ^ (not in super/sub-script) // double \\ means single \ // you can also insert magic codes defined above as _pi_ // but you need to use concat() Function to succeed
TextExt.inc/_ArNap [ Variables ]
[ Top ] [ TextExt.inc ] [ Variables ]
PURPOSE
Helper variable stores string parsed
SOURCE
#declare _ArNap = array[1];
TextExt.inc/Fonts, _FLibera, _FCourierI, _FTimes, _FSegoa, _FArialUni, _FArialRond, _FCooper, _FCorsiva [ Variables ]
[ Top ] [ TextExt.inc ] [ Variables ]
PURPOSE
Helper variables
SOURCE
#declare _FLibera = "LiberationMono-Regular.ttf"; // Liberation Mono, Regular #declare _FCourierI = "couri.ttf"; // italic Courier #declare _FTimes = "times.ttf"; // Times New Roman #declare _FSegoa = "segoesc.ttf"; // Segoa #declare _FArialUni = "arialuni.ttf"; // Arial - Unicode #declare _FArial = "arial.ttf"; // Arial - regular - no PL signs ;c #declare _FArialRond = "ARLRDBD.TTF" // Arial Rounded MT Bold - no PL signs ;c #declare _FCooper = "COOPBL.TTF"; // Cooper Black - no PL signs ;c #declare _FCorsiva = "MTCORSVA.TTF"; // MonoType Corsiva //----- shall be continued....
TextExt.inc/SubSupScale, SubShift, SupShift, UpPos, DnPos, SpcStub, _DotScalingFactor, _Dp, _HCur, _VCur, _TLen, _RFac, __Cnt [ Variables ]
[ Top ] [ TextExt.inc ] [ Variables ]
PURPOSE
Helper variables
SOURCE
#declare SubSupScale = 0.7; // lower and upper indexes are scaled by this factor from base font. #declare SubShift = 0.3; // relative down shift of subscripts #declare SupShift = 0.8; // relative up shift of superscripts #declare UpPos = SupShift; // vertical position of cursor - superscripts #declare DnPos = -SubShift; // vertical position of cursor - subscripts #declare _Dp = 0.1; // Depth of characters #declare SpcStub = "-"; // default fake space character #declare _DotScalingFactor = 0.75; // "dot" size. You don't need to change this - usually. #declare _HCur = 0.00; // current horizontal position of cursor #declare _VCur = 0.00; // current vertical position of cursor #declare _TLn = 0; // length of string parsed constant during parsing #declare _RFac = 0.69; // reduction factor for indexes #declare __Cnt = 0.00; // accounts calls to ParseNext() macro as POVRay doesn't implements "static" variables #declare __BCnt= 0.00; // {} block level counter #declare _tbox = 0.00; // size of parsed Text block
TextExt.inc/UTFCodes [ Variables ]
[ Top ] [ TextExt.inc ] [ Variables ]
PURPOSE
Constants with UTF codes of some common characters including polish national characters. Depends on existence of definition of given glyph.
Description in comments.
SOURCE
//==========[ PL_pl 'ogonki' ]========== #declare _a_ = "\u0105"; // ¹ #declare _A_ = "\u0104"; // ¥ #declare _c_ = "\u0107"; // æ #declare _C_ = "\u0106"; // Æ #declare _e_ = "\u0119"; // ê #declare _E_ = "\u0118"; // Ê #declare _l_ = "\u0142"; // ³ #declare _L_ = "\u0141"; // £ #declare _n_ = "\u0144"; // ñ #declare _N_ = "\u0143"; // Ñ #declare _o_ = "\u00F3"; // ó #declare _O_ = "\u00D3"; // Ó #declare _s_ = "\u015B"; // œ #declare _S_ = "\u015A"; // Œ #declare _X_ = "\u0179"; // #declare _x_ = "\u017A"; // Ÿ #declare _Z_ = "\u017B"; // ¯ #declare _z_ = "\u017C"; // ¿ // selected DE #declare _u_ = "\u00FC"; // ü #declare _U_ = "\u00DC"; // Ü #declare _oe_ = "\u00F6"; // ö #declare _OE_ = "\u00D6"; // Ö // #declare _at_ = "\u0040"; // @ #declare _spc_ = "\u0020"; // just Space #declare _Ao_ = "\u00C5"; // Angstrem #declare _mu_ = "\u00B5"; // greek mu #declare _cdot_ = "\u00B7"; // multiplication sign #declare _pi_ = "\u03C0"; // pi sign #declare _phi_ = "\u03c6"; // italic small phi #declare _ro_ = "\u03C1"; // rho #declare _tau_ = "\u03C4"; // tau #declare _tht_ = "\u03D1"; // theta small #declare _deg_ = "\u00B0"; // degree sign #declare _par_ = "\u00A7"; // paragraph § #declare _promil_ = "\u2030"; // promile ‰ // these symbols may depend on font applied #declare _inSet_ = "\u2208"; // belongs to the set #declare _diff_ = "\u00B9"; // difference (as in "2 different from 3") #declare _BgDt_ = "\u00B7"; // the big DOT #declare _idnt_ = "\u00BA"; // identity #declare _LePa_ = "\uFD3E"; // big Ornate left parenthesis #declare _RiPa_ = "\uFD3F"; // big Ornate right parenthesis #declare _inf_ = "\u221E"; // infinity symbol #declare _plumin_ = "\u00B1"; // plus/minus ± #declare _fromTo_ = "\u00F7"; // from-to math symbol, AKA division operator #declare _nabla_ = "\u2207"; // nabla operator (gradient, divergence) #declare _pdiff_ = "\u2202"; // partial difference #declare _nabl2_ = "\u2206"; // Laplace operator (nabla^2) // currencies (dollar is simply '$') #declare _pnd_ = "\u00A3"; // Pound sign #declare _yen_ = "\u00A5"; // Yen sign #declare _eur_ = "\u20AC"; // EURo sign // selected superscripts #declare _0p_ = "\u2070"; // upper index '0' (power '0') #declare _1p_ = "\u00B9"; // upper index '1' (ex. as in valence value in chemistry) #declare _2p_ = "\u00B2"; // power '2' #declare _3p_ = "\u00B3"; // power '3' #declare _4p_ = "\u2074"; // power '4' #declare _5p_ = "\u2075"; // power '5' #declare _6p_ = "\u2076"; // power '6' #declare _7p_ = "\u2077"; // power '7' #declare _8p_ = "\u2078"; // power '8' #declare _9p_ = "\u2079"; // power '9' // in fact rarely met #declare _ip_ = "\u2071"; // power 'i' #declare _np_ = "\u207F"; // power 'n' // quotients #declare _14_ = "\u00BC"; // 1/4 one quarter #declare _12_ = "\u00BD"; // 1/2 one half #declare _34_ = "\u00BE"; // 3/4 three quarter // digits and selected subscripts (tiny letters ) #declare _0s_ = "\u2080"; // index '0' #declare _1s_ = "\u2081"; // index '1' #declare _2s_ = "\u2082"; // index '2' #declare _3s_ = "\u2083"; // index '3' #declare _4s_ = "\u2084"; // index '4' #declare _5s_ = "\u2085"; // index '5' #declare _6s_ = "\u2086"; // index '6' #declare _7s_ = "\u2087"; // index '7' #declare _8s_ = "\u2088"; // index '8' #declare _9s_ = "\u2089"; // index '9' #declare _is_ = "\u1D62"; // index 'i' #declare _rs_ = "\u1D63"; // index 'r' #declare _ks_ = "\u2096"; // index 'k' #declare _ls_ = "\u2097"; // index 'l' #declare _ms_ = "\u2098"; // index 'm' #declare _ns_ = "\u2099"; // index 'n' #declare _os_ = "\u2092"; // index 'o' #declare _ps_ = "\u209A"; // index 'p' #declare _ss_ = "\u209B"; // index 's' #declare _ts_ = "\u209C"; // index 't' #declare _xs_ = "\u2093"; // index 'x'