I've been working on a bit of script for QGIS in order to automate atlas generation through the composer.
The only issue I've had is I can't align the composer label correctly. Here's the code sample:
composerLabel = QgsComposerLabel(c)
newFont = QFont("times", 40)
composerLabel.setFont(newFont)
composerLabel.setText("Hello world")
composerLabel.adjustSizeToText()
composerLabel.setItemPosition(c.paperWidth() / 2,0)
composerLabel.setHAlign(Qt.AlignCenter)
c.addItem(composerLabel)
Here's what the image output looks like
I've had a look at the API and scowered PYQGIS forums but no-one else sounds like they're having similar alignment issues. Can anyone see where I might be going wrong?
You only need add the ItemPositionMode in the setItemPosition method.
# add label
composerLabel = QgsComposerLabel(c)
newFont = QFont("times", 40)
composerLabel.setFont(newFont)
composerLabel.setText("Hello world")
composerLabel.adjustSizeToText()
composerLabel.setItemPosition(c.paperWidth() / 2,0,QgsComposerItem.UpperMiddle)
composerLabel.setHAlign(Qt.AlignCenter)
c.addComposerLabel(composerLabel)
Related
We are using the Autodesk Forge Viewer DiffTool extension, but we need to change one of the texts:
Every tutorial shows how add localization to your own extension, but I couldn't find how to change a translation in an existing extension you are using.
Moreover, without knowing what the translation key is, I would have "guess" it, which isn't really great either.
So, how do I change the translation for this text?
There is no supported way to hook into the translation service of the Viewer to change the text. If the translation is wrong, please let us know, and we can fix that on our side.
If you want to change the text for some other reasons, then one thing you could do is wait for the initialization of the extension's UI and change the button's content using DOM APIs:
let extensionConfig = {}
extensionConfig['mimeType'] = 'application/vnd.autodesk.revit'
extensionConfig['primaryModels'] = [model1]
extensionConfig['diffModels'] = [model2]
extensionConfig['diffMode'] = 'overlay'
extensionConfig['versionA'] = '2'
extensionConfig['versionB'] = '1'
extensionConfig['onInitialized'] = () => {
let button = document.getElementById("diffFacetsRemovedButton");
let label = button.nextSibling;
label.innerHTML = label.innerHTML.replace("Odebrat", "Něco jiného");
}
viewer.loadExtension('Autodesk.DiffTool', extensionConfig);
I know this question is very vague and doesn't probably have a single correct answer.
I just wanted to hear some input and create some content around advanced text styles in Compose. I hope it's fine.
Does anyone knows if there is a way to use Spans in compose?
I built a custom MultiAutocompleteTextView using the Views system that created chips using ChipSpan(...): ImageSpan(...).
It looks something like this:
How would you handle this in Compose?
Any input will be greatly appreciated! Thank you.
InlineTextContent might be what you are looking for. It uses AnnotatedString and placeholders and allows you to insert Composables inline with your text:
val text = buildAnnotatedString {
appendInlineContent("chip1", "Acid")
}
val inlineContent = mapOf(
"chip1" to InlineTextContent(
Placeholder(
width = 1.em, // calculate text width
height = 1.em, // calculate text height
placeholderVerticalAlign = PlaceholderVerticalAlign.AboveBaseline
)
) {
// call chip composable
}
)
BasicText(text = text, inlineContent = inlineContent)
If you are looking to use with Text, InlineTextContent could be useful. But In case of Textfield, seems like it is yet to be implemented. Checkout the below feature request filed in issue tracker.
When editing a vertex I would like to substitute the vertex symbol with SimpleMarkerSymbol and a TextSymbol but that appears to be impossible. Any suggestions on how I could do this? I want the appearance of dragging something like this (text + circle):
After taking some time to look at the API I've come to the conclusion it is impossible. Here is my workaround:
editor.on("vertex-move", args => {
let map = this.options.map;
let g = <Graphic>args.vertexinfo.graphic;
let startPoint = <Point>g.geometry;
let tx = args.transform;
let endPoint = map.toMap(map.toScreen(startPoint).offset(tx.dx, tx.dy));
// draw a 'cursor' as a hack to render text over the active vertex
if (!cursor) {
cursor = new Graphic(endPoint, new TextSymbol({text: "foo"}));
this.layer.add(cursor);
} else {
cursor.setGeometry(endPoint);
cursor.draw();
}
})
You could use a TextSymbol to create a point with font type having numbers inside the circle. Here is one place where you can find such font. http://www.fontspace.com/the-fontsite/combinumerals
Wont be exactly as shown in the image but close enough. Also some limitation it wont work with IE9 or lower (this is as per esri documentation, as I am using halo to get the white border).
Here is the working Jsbin : http://jsbin.com/hayirebiga/edit?html,output use point of multipoint
PS: I have converted the ttf to otf and then added the font as base64, which is optional. I did it as I could not add the ttf or otf to jsbin.
Well, Achieve this seems impossible so far however ArcGIS JS API provides a new Application/platform where you can generate single symbol online for your applications.
We can simply create all kind of symbols(Provide by ESRI) online and it gives you on the fly code which you just need to paste in your application.
This will help us to try different type of suitable symbols for the applications.
Application URL: https://developers.arcgis.com/javascript/3/samples/playground/index.html
Hoping this will help you :)
CMS users tend to paste anything into CMS text editors. To prevent website destruction - and as log as there's no non-wysiwyg editor (like markitup) for TYPO3, I would like to as least have some good old "force plain text paste" in place.
TYPO3's RTE has a button "pastetoggle, pastebehaviour, pasteastext". But I haven't managed to configure it so it's always active.
Also, there's an extension ad_rtepasteplain, but it produced no result in TYPO3 6.1.
Is there a usable way to implement paste-as-plain-text for TYPO3 6.x?
[EDIT]
I found (for user TSConfig)
setup.default.rteCleanPasteBehaviour
setup.override.rteCleanPasteBehaviour
as well as (for page TSConfig)
buttons.pastetoggle.setActiveOnRteOpen
buttons.pastetoggle.hidden
... none of which I got running yet. If that's the way to go: is there a working tutorial?
Got it. This is my current setup
RTE.default {
enableWordClean = 1
removeTrailingBR = 1
removeComments = 1
removeTags = center, font, o:p, sdfield, u
removeTagsAndContents = link, meta, script, style, title
hidePStyleItems = h5,h6,pre,address,div
// buttons
showButtons = chMode, formatblock, insertcharacter, removeformat, unorderedlist, orderedlist, outdent, indent, link, copy, cut, paste, showhelp, about,line, bold,pastetoggle, pastebehaviour, pasteastext
buttons.pastetoggle.setActiveOnRteOpen = 1
buttons.pastetoggle.hidden = 1
}
as well as setup.override.rteCleanPasteBehaviour=pasteStructure or plainText in user TSConfig
I have a multilanguage website and need automate the process of updating textlayers in psd-files from a csv-source.
I know that there might be glitches in the psp because of changed widths, but anyway it would help a lot to have the text inside the documents.
What are my options?
EDIT:
Murmelschlurmel has a working solution. Here is the link to the Adobe documentation.
http://livedocs.adobe.com/en_US/Photoshop/10.0/help.html?content=WSfd1234e1c4b69f30ea53e41001031ab64-740d.html
The format of the csv-file is not so nice: you need a column for each variable. I would expect a row for each variable.
It works with Umlaut (ä, ö etc)
EDIT 1:
Another solution is to use com to automate Photoshop. Thats nice if you have a couple of templates (buttons) that need changed text. Here is my script in python that might get you startet.
You need to have an excel file with columns:
TemplateFileName, TargetFileName, TargetFormat, Text
(ie template.psd, button1 , gif , NiceButton) .
The first row of the sheet is not used.
The psp template should only have 1 textlayer and can not have layergroups.
import win32com.client
import xlrd
spreadsheet = xlrd.open_workbook("text_buttons.xls")
sheet = spreadsheet.sheet_by_index(0)
psApp = win32com.client.Dispatch("Photoshop.Application")
jpgSaveOptions = win32com.client.Dispatch("Photoshop.JPEGSaveOptions")
jpgSaveOptions.EmbedColorProfile = True
jpgSaveOptions.FormatOptions = 1
jpgSaveOptions.Matte = 1
jpgSaveOptions.Quality = 1
gifSaveOptions = win32com.client.Dispatch("Photoshop.GIFSaveOptions")
for rowIndex in range(sheet.nrows):
if(rowIndex > 0):
template = sheet.row(rowIndex)[0].value
targetFile = sheet.row(rowIndex)[1].value
targetFileFormat = sheet.row(rowIndex)[2].value
textTranslated = sheet.row(rowIndex)[3].value
psApp.Open(r"D:\Design\Produktion\%s" % template )
doc = psApp.Application.ActiveDocument
for layer in doc.Layers:
if (layer.Kind == 2):
layer.TextItem.Contents = textTranslated
if(targetFileFormat == "gif"):
doc.SaveAs(r"D:\Design\Produktion\de\%s" % targetFile, gifSaveOptions, True, 2)
if(targetFileFormat == "jpg"):
doc.SaveAs(r"D:\Design\Produktion\de\%s" % targetFile, jpgSaveOptions, True, 2)
You can use "Data Driven Design" to do this. There is also a concept of data driven design in computer science, but as far as I can see this is not not related to the use of the word in Photoshop.
Here is how to proceed:
Load your image in Photoshop and define your variables with Image > Variable > Define.
Then convert your csv to a format Photoshop can read. I had the best experiences with tab delimted text.
Finally load the text file in Photoshop with Images > Variables > Data Set and let Photoshop save all iterations.
When I tried this first, I found that the Photoshop help file didn't provide enough details. I searched the Internet for photoshop "data set" and found some good tutorials, e.g. this one from digitaltutors.
It might be little bit off too much, but I have used Adobe AlterCast/Grphics server to handle exactly same issue.
Also if its just Text GIF/JPG image, you can use Python+PIL (Python Imaging Library).
Here is a sample code (works on Windows OS with Arial and Osaka fonts installed.)
#!/usr/bin/python
# -*- coding: utf-8 -*-
import ImageFont, ImageDraw, Image
#font = ImageFont.truetype("/usr/share/fonts/bitstream-vera/Vera.ttf", 24)
#font = ImageFont.truetype("futuratm.ttf", 18)
font = ImageFont.truetype("arial.ttf", 18)
im = Image.new("RGB", (365,20), "#fff")
draw = ImageDraw.Draw(im)
draw.text((0, 0), "Test Images", font=font, fill="#000")
im.save("TestImg_EN.gif", "GIF")
font = ImageFont.truetype("osaka.ttf", 18)
im = Image.new("RGB", (365,20), "#fff")
draw = ImageDraw.Draw(im)
draw.text((0, 0), u"テストイメージ", font=font, fill="#000")
im.save("TestImg_JP.gif", "GIF")