Font Selector

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Font Selector

Message par falsam »

Un outil qui insère une fonte dans votre éditeur sous la forme: LoadFont(#PB_Any, "Arial", 10, #PB_Font_Bold|#PB_Font_Italic)

Sauver le code ci-dessous et créer un exécutable (Exemple : Code Selector)

Code : Tout sélectionner

Define.s Message, FontName, FontStyle
Define.i FontSize, n

Result = FontRequester("Arial", 10, 0, RGB(0, 0, 0), #False)

If result  
  If SelectedFontStyle()  
    FontStyle=", "
    
    If SelectedFontStyle() & #PB_Font_Bold 
      FontStyle + "#PB_Font_Bold"
    EndIf
    
    If SelectedFontStyle() & #PB_Font_Italic
      FontStyle + "#PB_Font_Italic"
    EndIf
  
    If SelectedFontStyle() & #PB_Font_StrikeOut
      FontStyle + "#PB_Font_StrikeOut"
    EndIf
    
    If SelectedFontStyle() & #PB_Font_Underline
      FontStyle + "#PB_Font_Underline"
    EndIf 
  
    If SelectedFontStyle() & #PB_Font_HighQuality
      FontStyle + "#PB_Font_HighQuality"
    EndIf
    
    FontStyle = ReplaceString(FontStyle, "#PB", "|#PB",0, 4)
  EndIf
    
  Message = "LoadFont(#PB_Any, " + Chr(34)+SelectedFontName()+Chr(34) +", " + Str(SelectedFontSize()) + FontStyle +")" 
   
  SetClipboardText(Message)
  HandleIDESci=Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
  SendMessage_(HandleIDESci, #WM_PASTE,0,0) 
EndIf
Inscrivez ensuite cet exécutable dans les outils de votre éditeur de code (IDE). Ajouter une touche de raccourci (Exemple CTRL+ALT+F)

Image
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Font Selector

Message par falsam »

A mon avis les flags #PB_Font_StrikeOut, #PB_Font_Underline et #PB_Font_HighQuality ne seront jamais proposés :mrgreen:
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Répondre