Erweiterung für 'My Font Tool for Tablet PC'

  • Das genannte Programm gehört zu den Powertoys von Windows XP Tablet Edition.
    Es ermöglicht, die eigene Handschrift als TrueType Font zu kompilieren. Leider unterstützt das Programm selbst nur den englischen Zeichensatz und keine deutschen Umlaute.
    Mein kleines Script hebt die Schwäche zumindest teilweise auf und ermöglicht so das Hinzufügen von 12 weiteren Zeichen [ÄÖÜäöü߀°§´`]. Vielleicht kann es ja hier jemand gebrauchen.

    Spoiler anzeigen
    [autoit]

    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_outfile=..\My Font DE.exe
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("TrayAutoPause",0)

    [/autoit] [autoit][/autoit] [autoit]

    ;###################################################################
    ;# GUI erstellen
    ;###################################################################
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("German Support for My Font Tool for Tablet PC", 462, 117, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
    $Label3 = GUICtrlCreateLabel("Name der Schriftart:", 5, 7, 98, 17)
    $txtfontname = GUICtrlCreateInput("", 172, 5, 251, 21)
    $Label2 = GUICtrlCreateLabel("Fertige Schriftart speichern unter:", 5, 33, 160, 17)
    $txtfonttarget = GUICtrlCreateInput("", 172, 31, 251, 21)
    $cmdfonttarget = GUICtrlCreateButton("", 430, 32, 25, 20, 0)
    $Label1 = GUICtrlCreateLabel("Pfad der My Font Tool.exe:", 5, 59, 132, 17)
    $txtmyfontexe = GUICtrlCreateInput("", 172, 57, 251, 21)
    $cmdtxtmyfontexe = GUICtrlCreateButton("", 430, 58, 25, 20, 0)
    $cmdStart = GUICtrlCreateButton("Los!", 5, 85, 106, 26, 0)
    GUICtrlSetState($cmdStart, $GUI_DISABLE)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    ;###################################################################
    ;# Funktionen
    ;###################################################################

    [/autoit] [autoit][/autoit] [autoit]

    Func GetHTMX($sign)
    Local $InputFile2, $htmx, $ret
    $InputFile2 = FileOpen(@TempDir & "\MyFontDE\part2.ttx",0)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $htmx = FileReadLine($InputFile2)

    [/autoit] [autoit][/autoit] [autoit]

    If StringInStr ($htmx, 'mtx name="' & $sign &'" ', 1) Then
    If StringCompare($sign, "A", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="A"', 'name="Adieresis"')
    ElseIf StringCompare($sign, "O", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="O"', 'name="Odieresis"')
    ElseIf StringCompare($sign, "U", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="U"', 'name="Udieresis"')
    ElseIf StringCompare($sign, "a", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="a"', 'name="adieresis"')
    ElseIf StringCompare($sign, "o", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="o"', 'name="odieresis"')
    ElseIf StringCompare($sign, "u", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="u"', 'name="udieresis"')
    ElseIf StringCompare($sign, "s", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="s"', 'name="germandbls"')
    ElseIf StringCompare($sign, "B", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="B"', 'name="degree"')
    ElseIf StringCompare($sign, "C", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="C"', 'name="section"')
    ElseIf StringCompare($sign, "E", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="E"', 'name="Euro"')
    ElseIf StringCompare($sign, "F", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="F"', 'name="grave"')
    ElseIf StringCompare($sign, "G", 1) = 0 Then
    $ret = StringReplace($htmx, 'name="G"', 'name="acute"')
    EndIf
    FileClose($InputFile2)
    Return $ret
    EndIf
    WEnd
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func GetTTGlyph($sign)
    Local $InputFile2, $TTGlyph, $ret, $line
    $InputFile2 = FileOpen(@TempDir & "\MyFontDE\part2.ttx",0)
    $ret = ""
    While 1
    $TTGlyph = FileReadLine($InputFile2)

    [/autoit] [autoit][/autoit] [autoit]

    If StringInStr ($TTGlyph, 'TTGlyph name="' & $sign &'" ', 1) Then
    If StringCompare($sign, "A", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="A"', 'name="Adieresis"') & @CRLF
    ElseIf StringCompare($sign, "O", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="O"', 'name="Odieresis"') & @CRLF
    ElseIf StringCompare($sign, "U", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="U"', 'name="Udieresis"') & @CRLF
    ElseIf StringCompare($sign, "a", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="a"', 'name="adieresis"') & @CRLF
    ElseIf StringCompare($sign, "o", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="o"', 'name="odieresis"') & @CRLF
    ElseIf StringCompare($sign, "u", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="u"', 'name="udieresis"') & @CRLF
    ElseIf StringCompare($sign, "s", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="s"', 'name="germandbls"') & @CRLF
    ElseIf StringCompare($sign, "B", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="B"', 'name="degree"')
    ElseIf StringCompare($sign, "C", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="C"', 'name="section"')
    ElseIf StringCompare($sign, "E", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="E"', 'name="Euro"')
    ElseIf StringCompare($sign, "F", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="F"', 'name="grave"')
    ElseIf StringCompare($sign, "G", 1) = 0 Then
    $ret = StringReplace($TTGlyph, 'name="G"', 'name="acute"')
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Inhalt des Abschnitts auslesen
    Do
    $line = FileReadLine($InputFile2)
    $ret = $ret & $line & @CRLF
    Until StringInStr($line,"</TTGlyph>")

    [/autoit] [autoit][/autoit] [autoit]

    ;Funktion beenden
    FileClose($InputFile2)
    Return $ret
    EndIf
    WEnd
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func CreateFontFile()
    Local $ttxfolder, $InputFile1, $InputFile2, $Outputfile, $line
    $ttxfolder = EnvGet("APPDATA") & "\My Font Tool for Tablet PC"

    [/autoit] [autoit][/autoit] [autoit]

    MsgBox(64, "Hinweis", "Füllen Sie alle Felder aus, bestimmen Sie die Abstände, speichern Sie das Projekt und klicken Sie auf 'Compile'.")
    Run(GUICtrlRead($txtmyfontexe))

    [/autoit] [autoit][/autoit] [autoit]

    ProcessWait("TTX.exe")

    [/autoit] [autoit][/autoit] [autoit]

    While ProcessExists("TTX.exe")
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ;Datei kopieren
    If FileExists($ttxfolder & "\outputFont.ttx") Then
    FileCopy($ttxfolder & "\outputFont.ttx", @TempDir & "\MyFontDE\part1.ttx", 9)
    Else
    MsgBox(16, "Fehler", "Die Datei " & $ttxfolder & "\outputFont.ttx wurde nicht gefunden. Abbruch.")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Starten des 2. Durchlaufes
    MsgBox(64, "Hinweis", "Wechseln Sie wieder in den Tab 'Write'. Ändern Sie die Buchstaben entsprechend der folgenden Übersicht." _
    & @CRLF & "Speichern Sie das Projekt unter einem neuen Dateinamen ab. Die Änderungen von Abständen und Buchstaben" _
    & @CRLF & "die nicht in der Übersicht stehen werden ignoriert. Klicken Sie anschließend erneut auf 'Compile'." _
    & @CRLF & "A -> Ä ; a -> ä ; O -> Ö ; o -> ö ; U -> Ü ; u -> ü ; s -> ß ; B -> ° ; C -> § ; E -> € ; F -> ` ; G -> ´")

    [/autoit] [autoit][/autoit] [autoit]

    ProcessWait("TTX.exe")
    While ProcessExists("TTX.exe")
    Sleep(1000)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    SplashTextOn("Verarbeite Dateien", "Die Zeichen werden verarbeitet und die Schrift erstellt." & @CRLF & "Dies kann etwas dauern.", 450, 68)

    [/autoit] [autoit][/autoit] [autoit]

    ;Datei des 2. Durchlaufes kopieren
    If FileExists($ttxfolder & "\outputFont1.ttx") Then
    FileCopy($ttxfolder & "\outputFont1.ttx", @TempDir & "\MyFontDE\part2.ttx", 9)
    Else
    MsgBox(16, "Fehler", "Die Datei " & $ttxfolder & "\outputFont1.ttx wurde nicht gefunden. Abbruch.")
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Zusammenfügen der Schriftdateien
    If FileExists(@TempDir & "\MyFontDE\Output.ttx") Then
    FileDelete(@TempDir & "\MyFontDE\Output.ttx")
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $InputFile1 = FileOpen(@TempDir & "\MyFontDE\part1.ttx",0)
    $Outputfile = FileOpen(@TempDir & "\MyFontDE\Output.ttx",1)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $line = FileReadLine($InputFile1)
    If @error = -1 Then ExitLoop
    ;GlyphIDs hinzufügen
    If StringInStr($line, '<GlyphID id="97" name="asciitilde"/>') Then
    FileWriteLine($Outputfile, ' <GlyphID id="97" name="asciitilde"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="98" name="Adieresis"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="103" name="Odieresis"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="104" name="Udieresis"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="108" name="adieresis"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="124" name="odieresis"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="129" name="udieresis"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="137" name="germandbls"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="131" name="degree"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="134" name="section"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="188" name="Euro"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="67" name="grave"/>')
    FileWriteLine($Outputfile, ' <GlyphID id="141" name="acute"/>')
    ;Map-Codes hinzufügen
    ElseIf StringInStr($line, '<map code="0x7e" name="asciitilde"/><!-- TILDE -->') Then
    FileWriteLine($Outputfile, ' <map code="0x7e" name="asciitilde"/><!-- TILDE -->')
    FileWriteLine($Outputfile, ' <map code="0xc4" name="Adieresis"/><!-- LATIN CAPITAL LETTER A WITH DIAERESIS -->')
    FileWriteLine($Outputfile, ' <map code="0xd6" name="Odieresis"/><!-- LATIN CAPITAL LETTER O WITH DIAERESIS -->')
    FileWriteLine($Outputfile, ' <map code="0xdc" name="Udieresis"/><!-- LATIN CAPITAL LETTER U WITH DIAERESIS -->')
    FileWriteLine($Outputfile, ' <map code="0xe4" name="adieresis"/><!-- LATIN SMALL LETTER A WITH DIAERESIS -->')
    FileWriteLine($Outputfile, ' <map code="0xf6" name="odieresis"/><!-- LATIN SMALL LETTER O WITH DIAERESIS -->')
    FileWriteLine($Outputfile, ' <map code="0xfc" name="udieresis"/><!-- LATIN SMALL LETTER U WITH DIAERESIS -->')
    FileWriteLine($Outputfile, ' <map code="0xdf" name="germandbls"/><!-- LATIN SMALL LETTER SHARP S -->')
    FileWriteLine($Outputfile, ' <map code="0xb0" name="degree"/><!-- DEGREE SIGN -->')
    FileWriteLine($Outputfile, ' <map code="0xa7" name="section"/><!-- SECTION SIGN -->')
    FileWriteLine($Outputfile, ' <map code="0x20ac" name="Euro"/><!-- EURO SIGN -->')
    FileWriteLine($Outputfile, ' <map code="0x60" name="grave"/><!-- GRAVE ACCENT -->')
    FileWriteLine($Outputfile, ' <map code="0xb4" name="acute"/><!-- ACUTE ACCENT -->')
    ;TTGlyph und Contourinformationen hinzufügen
    ElseIf StringInStr($line, '</glyf>') Then
    FileWrite($Outputfile, GetTTGlyph("A"))
    FileWrite($Outputfile, GetTTGlyph("O"))
    FileWrite($Outputfile, GetTTGlyph("U"))
    FileWrite($Outputfile, GetTTGlyph("a"))
    FileWrite($Outputfile, GetTTGlyph("o"))
    FileWrite($Outputfile, GetTTGlyph("u"))
    FileWrite($Outputfile, GetTTGlyph("s"))
    FileWrite($Outputfile, GetTTGlyph("B"))
    FileWrite($Outputfile, GetTTGlyph("C"))
    FileWrite($Outputfile, GetTTGlyph("E"))
    FileWrite($Outputfile, GetTTGlyph("F"))
    FileWrite($Outputfile, GetTTGlyph("G"))
    FileWriteLine($Outputfile, ' </glyf>')
    ;HDMX hinzufügen
    ElseIf StringInStr($line, '</hdmxData>') Then
    FileWriteLine($Outputfile, ' Adieresis: ;')
    FileWriteLine($Outputfile, ' Odieresis: ;')
    FileWriteLine($Outputfile, ' Udieresis: ;')
    FileWriteLine($Outputfile, ' adieresis: ;')
    FileWriteLine($Outputfile, ' odieresis: ;')
    FileWriteLine($Outputfile, ' udieresis: ;')
    FileWriteLine($Outputfile, ' germandbls: ;')
    FileWriteLine($Outputfile, ' degree: ;')
    FileWriteLine($Outputfile, ' section: ;')
    FileWriteLine($Outputfile, ' Euro: ;')
    FileWriteLine($Outputfile, ' grave: ;')
    FileWriteLine($Outputfile, ' acute: ;')
    FileWriteLine($Outputfile, ' </hdmxData>')
    ;HMTX Informationen hinzufügen
    ElseIf StringInStr($line, '</hmtx>') Then
    FileWriteLine($Outputfile, GetHTMX("A"))
    FileWriteLine($Outputfile, GetHTMX("O"))
    FileWriteLine($Outputfile, GetHTMX("U"))
    FileWriteLine($Outputfile, GetHTMX("a"))
    FileWriteLine($Outputfile, GetHTMX("o"))
    FileWriteLine($Outputfile, GetHTMX("u"))
    FileWriteLine($Outputfile, GetHTMX("s"))
    FileWriteLine($Outputfile, GetHTMX("B"))
    FileWriteLine($Outputfile, GetHTMX("C"))
    FileWriteLine($Outputfile, GetHTMX("E"))
    FileWriteLine($Outputfile, GetHTMX("F"))
    FileWriteLine($Outputfile, GetHTMX("G"))
    FileWriteLine($Outputfile, ' </hmtx>')
    ElseIf StringInStr($line, 'developed by Philip Lanier 2004') Then
    $line = $line & ", German Language Support by Kai Sumann 2009"
    FileWriteLine($Outputfile, $line)
    Else
    FileWriteLine($Outputfile, $line)
    EndIf
    Wend
    FileClose($Outputfile)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;#######################################################################################
    ;# Script Start
    ;#######################################################################################
    Global $Temp

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $cmdtxtmyfontexe
    $Temp = FileOpenDialog("Pfad zur My Font Tool for Tablet PC.exe auswählen","","Ausführbare Dateien (*.exe)")
    If $Temp <> "" Then
    GUICtrlSetData($txtmyfontexe, $Temp)
    EndIf
    If GUICtrlRead($txtfonttarget) <> "" AND GUICtrlRead($txtmyfontexe) <> "" And GUICtrlRead($txtfontname) <> "" Then
    GUICtrlSetState($cmdStart, $GUI_ENABLE)
    Else
    GUICtrlSetState($cmdStart, $GUI_DISABLE)
    EndIf
    Case $cmdfonttarget
    ;$Temp = FileSaveDialog("Geben Sie den Speicherort der fertigen Schriftdatei an.","", "TrueType Dateien *.ttf")
    $Temp = FileSelectFolder ("Geben Sie den Speicherort der fertigen Schriftdatei an.", "" , 1)
    If $Temp <> "" Then
    GUICtrlSetData($txtfonttarget, $Temp)
    EndIf
    If GUICtrlRead($txtfonttarget) <> "" AND GUICtrlRead($txtmyfontexe) <> "" And GUICtrlRead($txtfontname) <> "" Then
    GUICtrlSetState($cmdStart, $GUI_ENABLE)
    Else
    GUICtrlSetState($cmdStart, $GUI_DISABLE)
    EndIf
    Case $txtfontname
    If GUICtrlRead($txtfonttarget) <> "" AND GUICtrlRead($txtmyfontexe) <> "" And GUICtrlRead($txtfontname) <> "" Then
    GUICtrlSetState($cmdStart, $GUI_ENABLE)
    Else
    GUICtrlSetState($cmdStart, $GUI_DISABLE)
    EndIf
    Case $cmdStart
    GUISetState(@SW_HIDE)
    ;Temporäre Dateien von My Font Tool löschen
    FileDelete(EnvGet("APPDATA") & "\My Font Tool for Tablet PC\*.*")
    CreateFontFile()
    ;Fontdatei in dem angegebenen Ordner kompilieren
    $TTXEXEPath = StringLeft(GUICtrlRead($txtmyfontexe), StringInStr(GUICtrlRead($txtmyfontexe),"\","", -1)-1) & "\TTX\TTX.exe"
    Run ($TTXEXEPath & " " & @TempDir & "\MyFontDE\Output.ttx")
    Sleep(2000)
    SplashOff()
    FileMove(@TempDir & "\MyFontDE\Output.ttf", GUICtrlRead($txtfonttarget) & "\" & GUICtrlRead($txtfontname) & ".ttf", 9)
    Sleep(1000)
    ;Eigene temporären Dateien löschen
    DirRemove(@TempDir & "\MyFontDE", 1)
    ProcessClose("My Font Tool for Tablet PC.exe")
    GUISetState(@SW_SHOW)
    EndSwitch
    WEnd

    [/autoit]

    Bugs: Keine Bekannt
    Schönheitsfehler: Der Installationspfad wird nicht automatisch ermittelt; Hinzufügen neuer Zeichen recht schwer

    2 Mal editiert, zuletzt von Bitboy (6. Januar 2010 um 16:33)