)Ej/6ddlmZddlmZmZmZmZmZddlmZm Z ddl m Z ddl m Z ddlmZddlmZmZddlmZmZdd lmZdd lmZmZdd lmZdd lmZdd lmZddlmZddlZddgZ GddZ!Gdde!eZ"Gdde!e e Z#dS))array)AnyCallableDictOptionalTuple) MAX_F2DOT14floatToFixedToFloat)LogMixin)AbstractPointPenotRound) LoggingPenPenError) TransformPenTransformPointPen) ttProgram) flagOnCurve flagCubic)Glyph)GlyphComponent)GlyphCoordinates)dropImpliedOnCurvePointsN TTGlyphPenTTGlyphPointPenc eZdZ ddeeeefdeddfdZdede e e e e e e ffd Z d Z dd Z dd ede e e e e e e fd eededdf dZdZ deddededee gefdefdZdS)_TTGlyphBasePenTglyphSethandleOverflowingTransformsreturnNcJ||_||_|dS)a Construct a new pen. Args: glyphSet (Dict[str, Any]): A glyphset object, used to resolve components. handleOverflowingTransforms (bool): See below. If ``handleOverflowingTransforms`` is True, the components' transform values are checked that they don't overflow the limits of a F2Dot14 number: -2.0 <= v < +2.0. If any transform value exceeds these, the composite glyph is decomposed. An exception to this rule is done for values that are very close to +2.0 (both for consistency with the -2.0 case, and for the relative frequency these occur in real fonts). When almost +2.0 values occur (and all other values are within the range -2.0 <= x <= +2.0), they are clamped to the maximum positive value that can still be encoded as an F2Dot14: i.e. 1.99993896484375. If False, no check is done and all components are translated unmodified into the glyf table, followed by an inevitable ``struct.error`` once an attempt is made to compile them. If both contours and components are present in a glyph, the components are decomposed. N)rrinit)selfrrs KC:\PYTHON\MyICR_Suite\python\Lib\site-packages\fontTools/pens/ttGlyphPen.py__init__z_TTGlyphBasePen.__init__s$>! +F( glyphNametransformationc|||}t|j||j|dSN) transformPengetattrr drawMethod)r#r'r(tpens r$ _decomposez_TTGlyphBasePen._decompose9sB   ~66: i($/::4@@@@@r&ct)z6 Check if the current path is closed. )NotImplementedErrorr#s r$ _isClosedz_TTGlyphBasePen._isClosedAs "!r&c>g|_g|_g|_g|_dSr*)pointsendPtstypes componentsr2s r$r"z_TTGlyphBasePen.initGs"   r& baseGlyphName identifierkwargsc >|j||fdS)z" Add a sub glyph. N)r8append)r#r9r(r:r;s r$ addComponentz_TTGlyphBasePen.addComponentMs%  ~>?????r&c|jrtd|jD}g}|jD] \}}||jvr|jd|d.|js |jr|r|||Ut}||_ d|ddD\|_ |_ td|ddD}|dkrR|jr2td|Drtd |D}|dd |d df|_ ||_||"|S) Nc3NK|] \}}|ddD]}|dkp|dkV!dS)N).0r'r(ss r$ z3_TTGlyphBasePen._buildComponents..]sf/Y'+ARr&z skipped non-existing component ''c34K|]}t|VdSr*r rEvs r$rGz3_TTGlyphBasePen._buildComponents..ns('O'Oq 'O'O'O'O'O'Or&rAc36K|]}t|dVdS)N)r rJs r$rGz3_TTGlyphBasePen._buildComponents..qs>##/0#Ar**######r&)rrrNc3@K|]}t|cxkodkncVdSrBNr rErFs r$rGz3_TTGlyphBasePen._buildComponents..usO<<-.K!((((q((((<<<<<<r&c3RK|]"}t|cxkrdkr nntn|V#dSrPrQrRs r$rGz3_TTGlyphBasePen._buildComponents..ys[++(3Q';';';';!';';';';'; ++++++r&rB)ranyr8rlogwarningr5r/rr'xytuple transformflagsr=)r#componentFlags overflowingr8r'r( components r$_buildComponentsz _TTGlyphBasePen._buildComponentsYs  + 37?K  )- ) ) %I~ --  !PI!P!P!PQQQ{ t? K  >:::&((I"+I 'O'ON122!"";M&N #,IO   i ( ( ( (r&rAFroundr\dropImpliedOnCurvesracH|std||}t}t |j|_|j|_td|j |_ | |r||_ d|_nwt|j|_t!j|_|jd|rt)||j||S)a Returns a :py:class:`~._g_l_y_f.Glyph` object representing the glyph. Args: componentFlags: Flags to use for component glyphs. (default: 0x04) dropImpliedOnCurves: Whether to remove implied-oncurve points. (default: False) zDidn't close last contour.Br&r`)r3rr_rrr5 coordinatesr6endPtsOfContoursrr7r[r"r8numberOfContourslenrProgramprogram fromBytecodertoInt)r#r\rbrar8glyphs r$rnz_TTGlyphBasePen.glyphs~~ 9788 8**>:: ,T[99!%C,,   1 *E %'E " "%()?%@%@E "%-//EM M & &s + + +" 0(///   # #% # 0 0 0 r&)Tr Nr*)rAF)__name__ __module__ __qualname__rrstrrboolr%rfloatr/r3r"r>r_rintrrrnrDr&r$rrs-1!!4S>*!&*!  !!!!FAAeUE5%FGAAAA""" %) @ @ @eUE5%FG @SM @  @  @ @ @ @'''V#$)& )0 &&&&"&  % &  &&&&&&r&rc eZdZdZdZeZ ddeee e fde de d dffd Z d e eefd ed dfd ZddZd e fdZd e eefd dfdZd e eefd dfdZddZddZddZddZxZS)ra Pen used for drawing to a TrueType glyph. This pen can be used to construct or modify glyphs in a TrueType format font. After using the pen to draw, use the ``.glyph()`` method to retrieve a :py:class:`~._g_l_y_f.Glyph` object representing the glyph. drawNTFrroutputImpliedClosingLiner cZt||||_dSr*)superr%ry)r#rrry __class__s r$r%zTTGlyphPen.__init__s. #>???(@%%%r&pttpcn|j||j|dSr*)r5r=r7)r#r}r~s r$ _addPointzTTGlyphPen._addPoints4 2 "r&cj|j|jdSr*)r5popr7r2s r$ _popPointzTTGlyphPen._popPoints,  r&cl|j p,|jo%|jdt|jdz kS)NrerN)r5r6rir2s r$r3zTTGlyphPen._isCloseds7K K CDKOs4;/?/?!/CC r&c<||tdSr*)rrr#r}s r$lineTozTTGlyphPen.lineTos r;'''''r&c|std||tdS)Nz+"move"-type point must begin a new contour.)r3rrrrs r$moveTozTTGlyphPen.moveTos>~~ JHII I r;'''''r&ct|dzdksJ|ddD]}||t|d||dddSdS)NrBrNre)rirrr#r5r}s r$curveTozTTGlyphPen.curveTos}6{{Q!####"+ * *B NN2y ) ) ) ) ": ! NN6":q ) ) ) ) ) " !r&ct|dksJ|ddD]}||d|d||dddSdS)NrNrer)rirrs r$qCurveTozTTGlyphPen.qCurveTosy6{{a"+ " "B NN2q ! ! ! ! ": ! NN6":q ) ) ) ) ) " !r&ct|jdz }|dks|jr*||jddzkr|dS|jsNd}|jr|jddz}|j||j|kr||dz}|j|dS)NrNrre)rir5r6rryr=)r#endPtstartPts r$ closePathzTTGlyphPen.closePathsDK  1$ A::$+:%4;r?Q3F*F*F NN    F, G{ .+b/A-{7#t{5'999     5!!!!!r&c.|dSr*)rr2s r$endPathzTTGlyphPen.endPaths r&)NTFro)rprqrr__doc__r-rr+rrrsrrtr%rrurvrrr3rrrrrr __classcell__r|s@r$rrsJL.2,0). AA4S>*A&*A#' A  AAAAAAE%,/ST 4    (ue|,((((((ue|,((((( ********""""&r&ceZdZdZdZeZdfd ZdefdZ dde e de ddfd Z dd Z dd eeefd e e dede e de e de ddfdZxZS)ra Point pen used for drawing to a TrueType glyph. This pen can be used to construct or modify glyphs in a TrueType format font. After using the pen to draw, use the ``.glyph()`` method to retrieve a :py:class:`~._g_l_y_f.Glyph` object representing the glyph. drawPointsr NcVtd|_dSr*)r{r"_currentContourStartIndex)r#r|s r$r"zTTGlyphPointPen.init s"  )-&&&r&c|jduSr*)rr2s r$r3zTTGlyphPointPen._isCloseds-55r&r:r;c ~|stdt|j|_dS)z' Start a new sub path. zDidn't close previous contour.N)r3rrir5r)r#r:r;s r$ beginPathzTTGlyphPointPen.beginPaths=~~ =;<< <),T[)9)9&&&r&c8|rtd|jt|jkr d|_dS|jr|jddznd}|jt|jdz d|_|j}t|t|D]\}||dkrN|dz }||krt|dz }||dkrt||<|dz}||dkt||<]dS)z+ End the current sub path. zContour is already closed.NrerNrcurve) r3rrrir5r6r=r7rangerr)r# contourStartr[ijs r$rzTTGlyphPointPen.endPaths1 >>   9788 8  )S-=-= = =-1D * F.2k@t{2**q  3t{++a/000)-& |SZZ00 ' 'AQx7""E|##E QAAh!mm(E!HFAAh!mm'a ' 'r&Fr} segmentTypesmoothnamec |rtd||jdnz|dvr |jtnV|dkr |jtn0|dkr|jdnt ||j|dS)z6 Add a point to the current sub path. z&Can't add a point to a closed contour.Nr)linemoveqcurver)r3rr7r=rAssertionErrorr5)r#r}rrrr:r;s r$addPointzTTGlyphPointPen.addPoint6s >>   ECDD D   J  a , , , J  k * * * * H $ $ J  k * * * * G # # J  g & & & & -- - 2r&ror*)NFNN)rprqrrrr-rr+r"rtr3rrsrrrrrurrrs@r$rrs4J$L......646666::HSM:C:D::::''''>&*"$(  %, c]  sm  SM  r&)$rtypingrrrrrfontTools.misc.fixedToolsr r fontTools.misc.loggingToolsr fontTools.pens.pointPenr fontTools.misc.roundToolsrfontTools.pens.basePenrrfontTools.pens.transformPenrrfontTools.ttLib.tablesrfontTools.ttLib.tables._g_l_y_frrrrrrmath__all__rrrrDr&r$rs77777777777777FFFFFFFF000000444444------77777777GGGGGGGG,,,,,,BBBBBBBB111111::::::<<<<<<DDDDDD  * +SSSSSSSSlQQQQQ*QQQhPPPPPox1APPPPPr&