Putting A Box Round A Text Run - For Powerpoint - powerpoint

I would like to put a box around a text run in Powerpoint. Specifically a border. For example, a word might have a light green background (done by highlighting) and a thin black border line.
I've solved the "highlighting with a light green background" part - using a RGB value. That's fine.
Is it feasible to draw a box boundary line round a run?
I'm specifically looking for an example XML fragment - if this is feasible. (I use python-pptx and augment it with my own XML confection.)

I don't believe so Martin. A run is not a shape, so it doesn't have a border that can be turned on or off or given a color. You can find an excerpt of the XML schema showing what elements and attributes can go in a run-properties element (<w:rPr>) here: https://python-pptx.readthedocs.io/en/latest/dev/analysis/txt-font-underline.html?highlight=CT_TextCharacterProperties#related-schema-definitions
It can have a ln child element, which corresponds to a pptx.dml.line.LineFormat object, but that's going to set the format of the font "outline", like if you want the interior of each letter to be a different color than its outline. You could create a LineFormat object for a run if you wanted to experiment with it using line = LineFormat(run.font._element).
The other test would be whether you can do such a thing from the PowerPoint application UI. If you can't do it on Windows PowerPoint, it's very unusual that you can do it from the XML (although there are a few cases). Mac PowerPoint can't do everything Windows PowerPoint can, so that's less of a compelling "proof".

Related

Why are my table border look weird in PDF viewers?

I generated a table with iText7 (C#):
var cell = new Cell().Add(new Paragraph(headers[c]).SetFont(font).SetFontColor(ColorConstants.WHITE).SetFontSize(size).SetBold());
cell.SetBackgroundColor(color);
cell.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
cell.SetPadding(0);
cell.SetBorder(new SolidBorder(1));
table.AddCell(cell);
Document has the table, but on certain scalings, it looks weird on the edges:
Taking a closer look on the image above:
If however I change the zoom in the viewer directly, it looks OK:
How do I get rid of these unnecessary parts from the border?
I'm attaching here the resulted PDF for reference:
Download sample PDF
I also noticed that on iText KB pages, there is this kind of behavior:
https://kb.itextpdf.com/home/it7kb/faq/how-do-i-change-the-border-color-of-a-pdfpcell
See the red and blue bars' left edges:
This behaviour is not uncommon in PDF or other print drivers where vectors are printed rather than plotter definitions (often called "Dangles". It would be worse if the definition was rounded or square, rather than butt, and join as "mitre" cannot apply, see below). The overlap is intentional (to ensure both lines are inclusive). In a laser drum print that may be desirable overkill, but disastrous for any inkjet or screen. It looks like the cell is not bordered by a box, but using common straight vectors. Again this is often desirable optimisation but not when the weight is not honoured. Thus it depends if the viewer is using the correct thickness.
All desktop PDF viewers (icluding Chrome and FireFox) I tested showed the lines correctly as clean overlap without "Dangles". Acrobat has a reputation for undesirably thickening or thinning its standard defined lines depending on its user settings.

How to measure margin between font-elements in XD?

It seems not possible to view the exact margin between font-elements in XD (dev-view). Below you'll find a screenshot of a situation where we need to measure the exact distance between two Font-elements (XD developer-view).
It needs to bypass the line-height, but it doesn't. To be able to do this, we need the line-height to be zero. But when we edit the line-height in XD for a word or sentence on a single row, XD does not change that line-height.
Anybody encountered the same situation?
In this example the line-height is 32. We go to XD. Change it to zero, save it and SHARE FOR DEVELOPMENT. But the line-height remains 32. Also changing it to 1 instead of zero won't make any difference.
To fix this issue, you have to select the Text within Adobe XD. Right Click and select Path > Convert to Path. The margins around the Text will disappear and when in DEVELOPMENT view it becomes possible to see the right margin. A small problem remains. When you want to edit the text when it's a shape, you have to delete it and place a new text and turn it into a shape again. the text when converted to a shape
The default selector in Adobe XD will not give you the exact margin between two text. You have to convert the text layer into paths (Convert to Outlines) to get the exact margin.
But remember after converting text layer into path the text cannot be edited because now the letter are separate vector shapes.
To convert text layer into Path, select the layer and goto Object>Path>Click Convert to Path
You can use the Guides to drag one below your text and another one on top of the second text, and then you can see the distance between the 2 guides.
Check this youtube video for a quick tutorial on it. This is going to be a manual action. I don't think there's a key to press to check the distance automatically.

Tool to recognize text in Image and edit it and create new image with edited text

Hi is there any tools which do the following steps:
Recognize Text in image
Edit the text
Create new image with ne text
In the general case, this is very difficult (especially for a picture).
You need a good OCR.
The OCR needs to be able to recognize the exact font.
If the background isn't a solid color, the OCR will be perturbed and possibly not able to extract the exact characters and erase them correctly.
But also, if there is a background, when you change the characters you need to reconstruct the background where characters have been erased.
Then the editor needs to paint the new text with the same rendering attributes (size, italics, outline...), which may be a difficult task.
Because of this complexity, the best option is often to do it by hand.

how is the calculation of rgb values done in the dialog "windows color and appearance"

In Windows 7 and Windows XP you can find the "Window Color and Appearance" dialog under "Control Panel\Appearance and Personalization\Personalization".
Changing "Color1" of item "3D-Border" will result in a change of the following entries in the registry key
[HKEY_CURRENT_USER\Control Panel\Colors]
containing the resulting rgb-values:
Group1 (same values):
InactiveTitle, AppWorkspace, ButtonShadow, Graytext
Group2 (same values, different to those of group1):
Scrollbar, ButtonHilight
Does anyone know how these value are being calculated from the given rgb-values of "Color1"?
After searching the web without results and playing around with many values I did not happen to find a plausible way of how to do this.
Does anyone know the rules for this?
Any help would be appreciated.
I uploaded some demo values, systematically dealing with values in the lower parts. Also a text file comparing the affected registry key [HKEY_CURRENT_USER\Control Panel\Colors] after change of Color to Red (255 0 0).
When you set the "3D Border" color to red, it changed the "Button Face" color to red and interpolated this color to generate various lighter and darker shades of red, which were used to set some related color values.
The point is to create a consistent-looking theme with minimal effort. All you need to do is set the "base" color for 3D objects, and all of the other colors are automatically calculated to ensure that objects have the appropriate 3D appearance.
Some of these values, like the highlight and shadow colors used for 3D objects, are not directly configurable from the control panel applet. However, they can be set manually in the registry, and you can call the SetSysColors function to update currently running applications.
Why do you think you need to know the actual algorithm that Windows is using? What problem are you trying to solve? What are you going to use this information to do?
I do not imagine that the exact algorithm is documented anywhere. The code has been part of the OS since at least Windows 95.

How to set g:text style to bold font in a Windows Gadget?

I'm developing a Vista/Win7 Desktop Gadget that uses a translucent g:background (doc) area with g:text (doc) on top. I'm adding the text via addTextObject (doc), and this all works as expected.
However, I can't figure out how to set that text to bold style. There doesn't seem to be a way to do this directly via the exposed properties that I can see, and I can't use regular text + CSS in this case due to the fact this text is placed onto a g:background object.
I have also tried specifying a bold font directly, such as Arial Bold (doesn't work) instead of Arial (works).
So how can this be done?
Edit: I have tried setting font-weight:bold for both the body and the g:background object that parents my text; no luck.
See Flip Calendar, by Jonathan Abbott. His code is usually well commented so maybe you can get some ideas from that.
EDIT
The source of my information was from the early days of Vista Beta 2 where that was the official word from MS. I also found the following response to a thread on the MSDN forums regarding the Flip Calendar gadget itself:
http://social.msdn.microsoft.com/Forums/en-US/sidebargadfetdevelopment/thread/841e9d5e-32e9-453f-bd0e-dc5a4e607c33/
The gadget has options for setting bold font on the day of the month (a g:text object) but on closer inspection it doesn't work. Sorry about that. The MS guys have been known to be wrong as well on one or more occasions. I can honestly say that I don't use the g:text object.
This means your only (well, non activex route) option is VML text, which provides a lot of flexibility on layout. However, you will have to place it on a fully opaque area of the gadget which is probably why you wanted to use the addTextObject in the first place. Gary Beene's site really helped me out when I was getting started, but it doesn't go into any detail on the v:textbox element and the v:textpath element, though the MSDN documentation goes into enough detail on these.
If you need to place the text on a non-fully opaque area of the gadget, then you could still go the VML route and place an image behind the text that acts as a shadow, starting out fully opaque and fading to fully transparent. This is how Microsoft does text in window title bars with aero enabled.
Alternatively, you could create an ActiveXObject that draws the text you need in the font you want and saves the image to a temporary file in the gadget folder. Then you set that to the src of an addImageObject. I've done something similar in a gadget and it's fast enough not to be noticeable. You can also set min/max dimensions so shrinking/stretching to fit becomes a breeze.

Resources