def GetFNum(fontname): """Same as Fm.GetFNum(), but maps a missing font to Monaco instead of the system font.""" if fontname <> Fm.GetFontName(0): fontid = Fm.GetFNum(fontname) if fontid == 0: fontid = Fonts.monaco else: fontid = 0 return fontid
def getruninfo(self): all = (WASTEconst.weDoFont | WASTEconst.weDoFace | WASTEconst.weDoSize) dummy, mode, (font, face, size, color) = self.ted.WEContinuousStyle(all) if not (mode & WASTEconst.weDoFont): font = None else: font = Fm.GetFontName(font) if not (mode & WASTEconst.weDoFace): fact = None if not (mode & WASTEconst.weDoSize): size = None return font, face, size
# A minimal text editor.
def getfontnames(): names = [] for i in range(256): n = Fm.GetFontName(i) if n: names.append(n) return names
def getfontsettings(self): from Carbon import Res (font, style, size, color) = self.ted.WEGetRunInfo(0)[4] font = Fm.GetFontName(font) return (font, style, size, color)
def GetPortFontSettings(port): return Fm.GetFontName(port.GetPortTextFont()), port.GetPortTextFace( ), port.GetPortTextSize()
tabsize = max(tabsize, 1) self.ted.WESetTabSize(tabsize) self.SetPort() Qd.EraseRect(self.ted.WEGetViewRect()) self.ted.WEUpdate(port.visRgn) def getfontsettings(self): from Carbon import Res (font, style, size, color) = self.ted.WEGetRunInfo(0)[4] font = Fm.GetFontName(font) return (font, style, size, color) def setfontsettings(self, (font, style, size, color)): self.SetPort() if type(font) <> StringType: font = Fm.GetFontName(font) self.fontsettings = (font, style, size, color) fontid = GetFNum(font) readonly = self.ted.WEFeatureFlag(WASTEconst.weFReadOnly, -1) if readonly: self.ted.WEFeatureFlag(WASTEconst.weFReadOnly, 0) try: self.ted.WEFeatureFlag(WASTEconst.weFInhibitRecal, 1) selstart, selend = self.ted.WEGetSelection() self.ted.WESetSelection(0, self.ted.WEGetTextLength()) self.ted.WESetStyle(WASTEconst.weDoFace, (0, 0, 0, (0, 0, 0))) self.ted.WESetStyle( WASTEconst.weDoFace | WASTEconst.weDoColor | WASTEconst.weDoFont | WASTEconst.weDoSize, (fontid, style, size, color)) self.ted.WEFeatureFlag(WASTEconst.weFInhibitRecal, 0)