TTF Text Font
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: TTF Text Font
hi
i correct the macro, copy the new code
for install the macro (copy/paste) see here How_to_install_macros Manual_method_1
and use as any editor of font
if the macro help you i can make a wiki page for other user
say it to me
mario
i correct the macro, copy the new code
for install the macro (copy/paste) see here How_to_install_macros Manual_method_1
and use as any editor of font
if the macro help you i can make a wiki page for other user
say it to me
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: TTF Text Font
Wow! That looks nice Mario! Now I'm jealous, I'm not on Windows but Linux
Re: TTF Text Font
hi
old macro Selecting Fonts for Annotation in Draft Workbench and old problem (persistent) with Windows 10
maybe change QtGui.QFileDialog by QtGui.QFontComboBox as photo as Libre office for Windows Linux ...
EDIT: remember Change Font in Macro Circular Text
mario
old macro Selecting Fonts for Annotation in Draft Workbench and old problem (persistent) with Windows 10
maybe change QtGui.QFileDialog by QtGui.QFontComboBox as photo as Libre office for Windows Linux ...
EDIT: remember Change Font in Macro Circular Text
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: TTF Text Font
I think I have it installed correctly. I can execute it from the "Execute Macro" window to get the macro's GUI. But the "OK" button doesn't do anything. Even with using Arial font. I opened the python window and don't see any messages there from the macro.mario52 wrote: ↑Sat Mar 23, 2019 3:38 pm hi
i correct the macro, copy the new code
for install the macro (copy/paste) see here How_to_install_macros Manual_method_1
and use as any editor of font
WindowsFont.png
if the macro help you i can make a wiki page for other user
say it to me
mario
I think I'm not understanding what you mean by "and use as any editor of font".
Maybe a wiki with step-by-step install and usage details with screenshots would be a good idea.
I think I forgot to mention, here is my FreeCAD version info:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Re: TTF Text Font
hi
no problem !
many fonts give an error i still have to search !!
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
let me know
mario
no problem !
many fonts give an error i still have to search !!
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
let me know
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: TTF Text Font
I can't get anything after I click the OK button. Nothing shows up in the window. Nothing shows up in the Model tree.
Comparing our version numbers everything matches (including the hash) except for the python, qt and OCC versions. Yours are above in the quote, and here are mine:
Python version: 3.6.6
Qt version: 5.6.2
OCC version: 7.3.0
I'm wondering if the Python 2.x vs Python 3.x is the cause of the problem. I downloaded my install from the releases page on GitHub, and the filename is tagged as RC3. The specific release page is here:
https://github.com/FreeCAD/FreeCAD/releases/tag/0.18
Re: TTF Text Font
hi
i install FreeCAD-0.18.16093.690774c-WIN-x64-RC3-installer.exe
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
and yes error ! i search for correct
ps: for see the error create by macro : View > Panel > check Report view and the error as displayed
mario
i install FreeCAD-0.18.16093.690774c-WIN-x64-RC3-installer.exe
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
and yes error ! i search for correct
ps: for see the error create by macro : View > Panel > check Report view and the error as displayed
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: TTF Text Font
hi
try this new macro run to .16 .17 .18 .19 (with the .19 version you have icons by type TTF, FON, OTF)
not perfect but ...
Macro_Win10_Fonts_PYMP.FCMacro
@wandererfan
by doing the tests with different fonts I remaquered an error in the construction of a font nature-pro.font in Draft.py (all FC version):
en faisant les test avec différentes fontes j'ai remaqué une erreur à la construction d'une fonte nature-pro.font dans Draft.py (toutes versions FC)
(il y en a d'autres avec certaines fontes mais pas encore cherché)
here the modification:
Text given : "Your"
before modification: after modification:
mario
try this new macro run to .16 .17 .18 .19 (with the .19 version you have icons by type TTF, FON, OTF)
not perfect but ...
Macro_Win10_Fonts_PYMP.FCMacro
Code: Select all
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
"""
***************************************************************************
* Copyright (c) 2019 <mario52> *
* *
* This file is a supplement to the FreeCAD CAx development system. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License (LGPL) *
* as published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* for detail see the LICENCE text file. *
* *
* This software is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this macro; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA *
***************************************************************************
* WARNING! All changes in this file will be lost and *
* may cause malfunction of the program *
***************************************************************************
"""
#Macro_Win10_Fonts_PYMP 02/05/2019
#
###############################################################################################################################
#OS: Windows 10 #OS: Windows 10 #OS: Windows 10
#Word size of OS: 64-bit #Word size of OS: 64-bit #Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit #Word size of FreeCAD: 64-bit #Word size of FreeCAD: 64-bit
#Version: 0.16.6706 (Git) #Version: 0.17.13541 (Git) #Version: 0.18.16093 (Git)
#Build type: Release #Build type: Release #Build type: Release
#Branch: releases/FreeCAD-0-16 #Branch: releases/FreeCAD-0-17 #Branch: releases/FreeCAD-0-18
#Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0#Hash: 9948ee4f1570df9216862a79705afb367b2c6ffb#Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
#Python version: 2.7.8 #Python version: 2.7.14 #Python version: 2.7.14
#Qt version: 4.8.7 #Qt version: 4.8.7 #Qt version: 4.8.7
#Coin version: 4.0.0a #Coin version: 4.0.0a #Coin version: 4.0.0a
#OCC version: 6.8.0.oce-0.17 #OCC version: 7.2.0 #OCC version: 7.2.0
###############################################################################################################################
#OS: Windows 10
#Word size of OS: 64-bit
#Word size of FreeCAD: 64-bit
#Version: 0.19.16523 (Git)
#Build type: Release
#Branch: master
#Hash: 9b3ec233c8b21e0df66fada487cd10f471d60cac
#Python version: 3.6.6
#Qt version: 5.6.2
#Coin version: 4.0.0a
#OCC version: 7.3.0
###############################################################################################################################
__title__ = "Macro_Win10_Fonts_PYMP"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.01"
__date__ = "2019/05/02" #YYYY/MM/DD
#import PySide2
#from PySide2 import QtGui ,QtCore
#from PySide2.QtGui import *
#from PySide2.QtCore import *
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
import Draft, Part, PartGui, FreeCADGui, FreeCAD
from FreeCAD import Base
import math
from math import sqrt, pi, sin, cos, asin
import re
Gui = FreeCADGui
App = FreeCAD
import os, time, sys
import platform
#import glob
#files_TTF = glob.glob(self.pathFont + "/*.TTF")
##################################
import matplotlib
import matplotlib.font_manager as fontman
import operator
from operator import itemgetter, attrgetter, methodcaller # pour sort
#from matplotlib.ft2font import FT2Font
#from matplotlib.font_manager import FontProperties
##################################
global PolicePath
if platform.system() == "Windows" :
PolicePath = "C:/Windows/Fonts/ARIAL.TTF"
elif platform.system() == "Linux" :
PolicePath = "/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-M.ttf"
elif platform.system() == "Darwin":
PolicePath = "/Library/Fonts/Arial.ttf"
else:
PolicePath = "C:/Windows/Fonts/ARIAL.TTF"
nomPolice = os.path.basename(PolicePath).split('.')[0]
#### Config Begin #######################################
#
global setColorTTF ; setColorTTF = "blue" # .TTF color by "name" or hexa "#ffaa00"
global setColorFON ; setColorFON = "orange" # .FON color by "name" or hexa "#ffaa00"
global setColorOTF ; setColorOTF = "green" # .OTF color by "name" or hexa "#ffaa00"
global setColorPOL ; setColorPOL = "black" # .OTHER color by "name" or hexa "#ffaa00"
#####
global setSystemFonts ; setSystemFonts = 1 # 0 = matplotlib.font_manager.list_fonts() # fait toutes les fontes ? (dans tous les dossiers et sous dossiers du DD)
# 1 = fontman.findSystemFonts(path) # fait toutes les fontes du repertoire (et dans tous les sous dossiers)
#####
global seTtextAlignement ; seTtextAlignement = 0 # 0 = AlignLeft (default)
# 1 = AlignCenter
# 2 = AlignRight
#####
#### Config End #########################################
setIconTTF = [
"16 16 6 1",
" c None",
". c #204A87",
"+ c None",
"@ c #729FCF",
"# c #CC0000",
"$ c #EDD400",
".+++++++++++@@@@",
".++++++++@+@++@@",
".++#####++++@@+@",
".+++$#$$$++@+@+@",
".++++#$+++++++@+",
".++++#$#####++++",
".++++#$+$#$$$+++",
".++++#$++#$+++++",
".@++++$++#$+###+",
".@@++++++#$+#$$$",
"..@@+++++#$+#$++",
"...@@+++++$+###+",
"....@@++++++#$$$",
".....@@+++++#$++",
"......@@+++++$++",
"................"]
setIconFON = [
"16 16 6 1",
" c None",
". c #204A87",
"+ c None",
"@ c #F57900",
"# c #CC0000",
"$ c #EDD400",
".+++++++++++@@@@",
".++++++++@+@++@@",
".++###++++++@@+@",
".++#$$$++++@+@+@",
".++#$+++++++++@+",
".++###+###++++++",
".++#$$$#$#$+++++",
".++#$++#$#$+++++",
".@++$++#$#$##+#+",
".@@++++#$#$##$#$",
"..@@+++###$#$##$",
"...@@+++$$$#$##$",
"....@@+++++#$+#$",
".....@@++++#$+#$",
"......@@++++$++$",
"................"]
setIconOTF = [
"16 16 6 1",
" c None",
". c #204A87",
"+ c None",
"@ c #4E9A06",
"# c #CC0000",
"$ c #EDD400",
".+++++++++++@@@@",
".++++++++@+@++@@",
".++###++++++@@+@",
".++#$#$++++@+@+@",
".++#$#$+++++++@+",
".++#$#$###++++++",
".++#$#$+#$$+++++",
".++###$+#$++++++",
".@++$$$+#$+###++",
".@@+++++#$+#$$$+",
"..@@++++#$+#$+++",
"...@@++++$+###++",
"....@@+++++#$$$+",
".....@@++++#$+++",
"......@@++++$+++",
"................"]
setIconPOL = [
"16 16 12 1",
" c None",
". c #204A87",
"+ c None",
"@ c #06989A",
"# c #73D216",
"$ c #000000",
"% c #75507B",
"& c #729FCF",
"* c #CC0000",
"= c #F57900",
"- c #EDD400",
"; c #4E9A06",
".+++++++++++@#$%",
".++++++++$+#++&$",
".++***++++++=@+%",
".++*-*-++++*+&+$",
".++*-*-+++++++*+",
".++***-***++++++",
".++*---*-*-+++++",
".++*-++*-*-+++++",
".$++-++*-*-*++++",
".*@++++*-*-*-+++",
"..#*+++***-*-+++",
"...;#+++---*-+++",
"....%=+++++*-+++",
".....;$++++****+",
"......@%++++----",
"................"]
def createSpace(texte): # detecte majuscule et ajoute un espace devant la lettre
# return createSpace(TexTe) = Tex Te , if createSpace(TEXTE) = TEXTE
if texte.isupper():
stringSpace = texte
else:
try:
stringSpace = texte[0]
for i in texte[1:]:
if re.search(r"[A-Z]", i): i = " " + i
stringSpace += i
except Exception:
stringSpace = texte
return stringSpace
def family(chaine):
# return family(chaine)[1] = Family , family(chaine)[2] = typeCar (form [a, b, c ...]
famille = typeCar = ""
try:
if chaine.find('-') != -1:
famille = chaine[:chaine.find('-')]
typeCar = chaine[chaine.find('-')+1:]
else:
famille = chaine
typeCar = ""
except Exception:
famille = chaine
typeCar = ""
typeCar = str(createSpace(typeCar)).split()
return [createSpace(famille), typeCar]
class Ui_MainWindow(object):
def __init__(self ):
self.window = MainWindow
##path###############################################################
#self.path = FreeCAD.ConfigGet("AppHomePath") # path FreeCAD installation
#self.path = FreeCAD.ConfigGet("UserAppData") # path FreeCAD User data
#self.path = "your path" # your directory path
param = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")# macro path
self.path = param.GetString("MacroPath","") + "/" # macro path
self.path = self.path.replace("\\","/") # convert the "\" to "/"
#print( "Path for the icons : " , self.path ) #
#####################################################################
####font textEdit
self.nomPolice = "Arial"
self.FontSize = 10.0
self.fonteComp = ""
self.font = QtGui.QFont()
####font textEdit
self.red = (204.0 / 255.0)
self.green = (204.0 / 255.0)
self.blue = (204.0 / 255.0)
self.alpha = 1.0 # 1.0 = visibility max (opacity)
####global font
self.fontGlobal_08 = QtGui.QFont() #
self.fontGlobal_08.setFamily("Arial") #
self.fontGlobal_08.setPointSize(8) #
####global font
self.tableau = [] #Index (), [chemin plus nom fichier (nomPathPolice), nom sans extension (nomSimple), nomSimpleExt (nomSimple + Ext)]
self.index = 0 #Index ()
def setupUi(self, MainWindow):
global setSystemFonts
global setColorTTF
global setColorFON
global setColorOTF
global setColorPOL
global seTtextAlignement
self.window = MainWindow
MainWindow.setObjectName(("MainWindow"))
MainWindow.resize(450, 230)
MainWindow.setMinimumSize(QtCore.QSize(450, 230))
# MainWindow.setMaximumSize(QtCore.QSize(450, 230))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(("centralwidget"))
self.textEdit = QtGui.QTextEdit(self.centralwidget)
self.textEdit.setGeometry(QtCore.QRect(20, 20, 410, 90))
# ####
# self.textEdit = QtGui.QFont() #
# self.textEdit.setFamily("Arial") #
# self.textEdit.setFont(self.textEditFont) #
# self.textEdit.setPointSize(self.FontSize) #
# ####
self.textEdit.setObjectName(("textEdit"))
self.textEdit.setText("Your text here")
self.textEdit.setToolTip("Your text here" + "\n\n"
"It is possible that the font is not represented" + "\n"
"in its original form in the window of the macro and" + "\n"
"in the combobox list" + "\n\n"
"But the representation is exact in 3D view of FreeCAD")
self.label_NameFile = QtGui.QLabel(self.centralwidget)
self.label_NameFile.setGeometry(QtCore.QRect(20, 125, 410, 20))
self.label_NameFile.setFont(self.fontGlobal_08)
self.label_NameFile.setObjectName("label_NameFile")
self.fontL = QtGui.QFont() #
self.fontL.setFamily("Arial") #
self.fontL.setPointSize(10.0) #
self.label_NameFile.setFont(self.fontL)
######################
self.comboBoxPy = QtGui.QComboBox(self.centralwidget)
self.comboBoxPy.setGeometry(QtCore.QRect(20, 155, 410, 22))
self.comboBoxPy.setObjectName("comboBoxPy")
self.comboBoxPy.setToolTip("Choice your Font")
####
#self.pathFont = PolicePath[:-10]
self.pathFont = PolicePath[:len(PolicePath)-(PolicePath[::-1].index("/"))-1]
####
#####################################################################################
if setSystemFonts == 0:
files_All_Fonts = matplotlib.font_manager.list_fonts(self.pathFont,"*.TTF") # fait toutes les fontes ? (dans tous les dossiers et sous dossiers du DD)
else:
files_All_Fonts = fontman.findSystemFonts(self.pathFont) # fait toutes les fontes (et dans tous les sous dossiers)
self.tableau = []
self.index = 0
for fonte in files_All_Fonts:
####
nomPathPolice = fonte.replace("\\","/") # convert the "\" to "/"
nomFichier = nomPathPolice.split("/") # complet split
nomSimpleExt = nomFichier[-1] # nom avec extension
nomSimple = nomFichier[-1][:-4] # nom sans extension
extension = nomPathPolice[nomPathPolice.find('.')+1:].upper()
####
self.tableau.append([0, nomPathPolice, nomSimple, nomSimpleExt.upper(), extension.upper()])
self.tableau = sorted(self.tableau, key=itemgetter(3)) # sorted by nomSimple.upper()
for line in range(len(self.tableau)): # enleve les doubles (bon)
try:
if self.tableau[line][2] == self.tableau[line + 1][2]:
del(self.tableau[line + 1])
self.tableau[line][0] = line # ajoute le numero de ligne
# try:
# print(self.tableau[line][1]," ",self.tableau[line][2]," ", fontman.FontProperties(self.tableau[line][2]))#ok Properties
# except Exception:
# None
if self.tableau[line][2].upper() == "ARIAL": # detecte la fonte de base
self.index = line
### ####Section common color and font#########################
model = self.comboBoxPy.model()
if self.tableau[line][4] == "TTF":
item = QtGui.QStandardItem(QtGui.QPixmap(setIconTTF), str(line))
item.setForeground(QtGui.QColor(setColorTTF))
elif self.tableau[line][4] == "FON":
item = QtGui.QStandardItem(QtGui.QPixmap(setIconFON), str(line))
item.setForeground(QtGui.QColor(setColorFON))
elif self.tableau[line][4] == "OTF":
item = QtGui.QStandardItem(QtGui.QPixmap(setIconOTF), str(line))
item.setForeground(QtGui.QColor(setColorOTF))
else:
item = QtGui.QStandardItem(QtGui.QPixmap(setIconPOL), str(line))
item.setForeground(QtGui.QColor(setColorPOL))
if seTtextAlignement == 0:
item.setTextAlignment(QtCore.Qt.AlignLeft)
elif seTtextAlignement == 1:
item.setTextAlignment(QtCore.Qt.AlignCenter)
elif seTtextAlignement == 2:
item.setTextAlignment(QtCore.Qt.AlignRight)
### ####Section item color end################################
### ####Section setfont Family################################
typeCar = font = ""
font = QtGui.QFont()
#font = item.font()
font.setFamily(family(self.tableau[line][2])[0])
typeCar = family(self.tableau[line][2])[1]
font.setBold(False)
font.setItalic(False)
if len(typeCar) > 0:
for option in typeCar:
if option == "Bold":
font.setBold(True)
if (option == "Italic") or (option == "It") or (option == "Slanted"):
font.setItalic(True)
if option == "Oblique":
font.setItalic(True)
#'Bold''Regular''Slanted''Italic''Medium''Extra''Light''Condensed''Black''It''Semibold'
font.setPixelSize(15)
item.setFont(font)
### ####Section setfont Family################################
model.appendRow(item)
self.comboBoxPy.setItemText(line, self.tableau[line][2])
### ####Section common color and font#########################
except Exception:
None
####################################################################################
self.label_NameFile.setText(self.tableau[self.index][1])
self.comboBoxPy.setCurrentIndex(self.index)
self.fonteComp = self.tableau[self.index][1]
####
self.textEditFont = QtGui.QFont() #
self.textEditFont.setFamily(family(self.tableau[line][2])[0])
self.textEditFont.setPointSize(self.FontSize)#
self.textEdit.setFont(self.textEditFont) #
####
verPython = sys.version_info
if verPython.major < 3:
self.comboBoxPy.currentIndexChanged.connect(self.on_fontComboBoxPython)
else: # Qt 5
QtCore.QObject.connect(self.comboBoxPy, QtCore.SIGNAL("currentIndexChanged(int)"), self.on_fontComboBoxPython)
##########################
self.PB_OK = QtGui.QPushButton(self.centralwidget)
self.PB_OK.setGeometry(QtCore.QRect(20, 185, 75, 23))
self.PB_OK.setToolTip("Validate")
self.PB_OK.setFont(self.fontGlobal_08)
self.PB_OK.setObjectName(("PB_OK"))
self.PB_OK.clicked.connect(self.on_PB_OK) # ""
self.PB_color = QtGui.QPushButton(self.centralwidget)
self.PB_color.setGeometry(QtCore.QRect(104, 185, 75, 23))
self.PB_color.setToolTip("Text color")
self.PB_color.setFont(self.fontGlobal_08)
self.PB_color.setObjectName(("PB_color"))
self.PB_color.clicked.connect(self.on_PB_color) # ""
self.doubleSpinBox_1 = QtGui.QDoubleSpinBox(self.centralwidget)
self.doubleSpinBox_1.setGeometry(QtCore.QRect(187, 185, 50, 23))
self.doubleSpinBox_1.setMinimum(0.0)
self.doubleSpinBox_1.setMaximum(10000.0)
self.doubleSpinBox_1.setSingleStep(1.0)
self.doubleSpinBox_1.setValue(self.FontSize)
self.doubleSpinBox_1.setFont(self.fontGlobal_08)
self.doubleSpinBox_1.setToolTip("Dimension of the Shape")
self.doubleSpinBox_1.setObjectName("doubleSpinBox_1")
self.doubleSpinBox_1.valueChanged.connect(self.on_doubleSpinBox_1_valueChanged)#connect on def "on_doubleSpinBox_1_valueChanged"
self.checkBox_1 = QtGui.QCheckBox(self.centralwidget)
self.checkBox_1.setGeometry(QtCore.QRect(245, 185, 50, 23))
self.checkBox_1.setFont(self.fontGlobal_08)
self.checkBox_1.setToolTip("Create text")
self.checkBox_1.setObjectName(("checkBox_1"))
self.checkBox_1.setChecked(False)
# self.checkBox_1.clicked.connect(self.on_checkBox_1_clicked)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(__title__ + " (" + str(self.index) + "/" + str(len(self.tableau)) + ") (" + __version__ + " / " + __date__ + ")")
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenetre en avant
self.PB_OK.setText("Ok")
self.PB_color.setText("Color")
self.checkBox_1.setText("Text")
def on_doubleSpinBox_1_valueChanged(self,value):
self.FontSize = value
self.font.setPointSize(self.FontSize)
self.textEdit.setCurrentFont(self.font)
self.textEdit.setFont(self.font)
def on_fontComboBoxPython(self,indeX): # 0: for fontComboBoxPython
self.index = indeX
MainWindow.setWindowTitle(__title__ + " (" + str(self.index) + "/" + str(len(self.tableau)) + ") (" + __version__ + " / " + __date__ + ")")
self.label_NameFile.setText(self.tableau[self.index][1])
famille = typeCar = self.font = ""
self.font = QtGui.QFont()
typeCar = family(self.tableau[self.index][2])[1]
self.font.setBold(False)
self.font.setItalic(False)
if len(typeCar) > 0:
for option in typeCar:
if option == "Bold":
self.font.setBold(True)
if (option == "Italic") or (option == "It") or (option == "Slanted"):
self.font.setItalic(True)
if option == "Oblique":
self.font.setItalic(True)
#'Bold''Regular''Slanted''Italic''Medium''Extra''Light''Condensed''Black''It''Semibold'
self.font.setFamily(family(self.tableau[self.index][2])[0])
self.font.setPointSize(self.FontSize)
self.textEdit.setCurrentFont(self.font)
self.textEdit.setFont(self.font)
####
self.fonteComp = self.tableau[self.index][1]
# FreeCAD.Console.PrintMessage(str(self.index) + " , " + self.tableau[self.index][1] + " , " + self.tableau[self.index][2] + " , ' " + famille + "' , ' " + typeCar + " ' \n")
def on_PB_OK(self):
global PolicePath
try: #
texte = unicode(self.textEdit.toPlainText()) # ori
except Exception: #Qt version: 5.6.2
texte = self.textEdit.toPlainText() # Qt 5.6.2 error unicode
if texte != "":
tx = Draft.makeShapeString(String=texte, FontFile = self.fonteComp, Size = self.FontSize, Tracking = 0.0)
tx.Label = self.tableau[self.index][2]
tx.ViewObject.ShapeColor = (self.red, self.green, self.blue) # color of ShapeString
## Texte
if self.checkBox_1.isChecked():
tx2 = Draft.makeText([texte],point=FreeCAD.Vector(0.0,0.0,0.0))
tx2.ViewObject.FontName = self.tableau[self.index][1]
tx2.ViewObject.TextColor = (self.red, self.green, self.blue) # color of text
tx2.ViewObject.FontSize = self.FontSize
tx2.Label = self.tableau[self.index][2]
FreeCAD.ActiveDocument.recompute()
FreeCAD.Console.PrintMessage("___________________" + "\n")
FreeCAD.Console.PrintMessage(texte + "\n")
FreeCAD.Console.PrintMessage(self.tableau[self.index][1] + "\n")
FreeCAD.Console.PrintMessage(self.tableau[self.index][2] + "\n")
FreeCAD.Console.PrintMessage(str(self.FontSize) + "\n")
FreeCAD.Console.PrintMessage("___________________" + "\n")
else:
FreeCAD.Console.PrintMessage("Not string" + "\n")
def on_PB_color(self):
self.PB_color.setStyleSheet("background-color: QPalette.Base")
self.window.hide()
couleur = QtGui.QColorDialog.getColor()
if couleur.isValid():
self.red = couleur.redF()
self.green = couleur.greenF()
self.blue = couleur.blueF()
self.alpha = couleur.alphaF()
self.PB_color.setStyleSheet("background-color: " + couleur.name())
self.window.show()
#______________________________________________________________________________________
doc = FreeCAD.ActiveDocument
if doc == None:
doc = FreeCAD.newDocument()
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
by doing the tests with different fonts I remaquered an error in the construction of a font nature-pro.font in Draft.py (all FC version):
en faisant les test avec différentes fontes j'ai remaqué une erreur à la construction d'une fonte nature-pro.font dans Draft.py (toutes versions FC)
(il y en a d'autres avec certaines fontes mais pas encore cherché)
here the modification:
Code: Select all
line 5973
#ori if face.Surface.Axis.z < 0.0:
#ori face.reverse()
##modif#########
try:
if face.Surface.Axis.z < 0.0:
face.reverse()
except Exception:
None
##modif#########
before modification: after modification:
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: TTF Text Font
Hi
final version of the macro Macro_Fonts_Win10_PYMP
(FC 0.16.6706 (Git) to 0.19.16523 (Git))
enjoy
mario
final version of the macro Macro_Fonts_Win10_PYMP
(FC 0.16.6706 (Git) to 0.19.16523 (Git))
enjoy
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
My macros on Gist.github here complete macros Wiki and forum.
Re: TTF Text Font
Great! Must replace the draft's "string shape".